output.type.slice(...).toLocaleUpperCase is not a function #22001

Closed
opened 2026-02-21 20:15:13 -05:00 by yindo · 1 comment
Owner

Originally created by @fatelei on GitHub (Jan 30, 2026).

Originally assigned to: @fatelei on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.4

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. create mcp tool,mcp tool output schema has union type
  2. create workflow and add mcp tool, it broken
Image

✔️ Expected Behavior

no error

Actual Behavior

Image
Originally created by @fatelei on GitHub (Jan 30, 2026). Originally assigned to: @fatelei on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.4 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. create mcp tool,mcp tool output schema has union type 2. create workflow and add mcp tool, it broken <img width="1078" height="1154" alt="Image" src="https://github.com/user-attachments/assets/c7647376-a150-4936-bf91-13df7b73b8a6" /> ### ✔️ Expected Behavior no error ### ❌ Actual Behavior <img width="1078" height="1154" alt="Image" src="https://github.com/user-attachments/assets/060b9782-e47a-4e65-96c2-623a91ecc2bf" />
yindo added the 🐞 bug label 2026-02-21 20:15:13 -05:00
yindo closed this issue 2026-02-21 20:15:13 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 30, 2026):

This error happens because your MCP tool's output schema uses a union type (like type: ['string', 'null']), but Dify v1.11.4 doesn't normalize this, so the frontend tries to call string methods on an array or undefined, causing the crash. The backend passes the schema as-is, and the frontend expects output.type to always be a string, which isn't guaranteed with union types in JSON Schema. This is a known issue and has been reported in earlier versions as well [example].

Recent Dify versions added utility functions to safely handle union types and normalize schema types before using them, which prevents this error [PR ref].

For v1.11.4, you have a few options:

  • Avoid union types in your MCP tool output schema—use a single string type if possible.
  • If you must use union types, preprocess or normalize the schema in your own code before it reaches the workflow node, or use a code/template node to transform the output to a simple type.
  • If you can, upgrade to a newer Dify version where this is fixed.

For schema design, always ensure the output schema's type is a string, not an array, and avoid constructs like oneOf or anyOf at the top level unless you know the frontend can handle them. This will prevent similar issues in the future.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 30, 2026): <!-- Answer --> This error happens because your MCP tool's output schema uses a union type (like `type: ['string', 'null']`), but Dify v1.11.4 doesn't normalize this, so the frontend tries to call string methods on an array or undefined, causing the crash. The backend passes the schema as-is, and the frontend expects `output.type` to always be a string, which isn't guaranteed with union types in JSON Schema. This is a known issue and has been reported in earlier versions as well [[example](https://github.com/langgenius/dify/issues/21890)]. Recent Dify versions added utility functions to safely handle union types and normalize schema types before using them, which prevents this error [[PR ref](https://github.com/langgenius/dify/pull/29035)]. For v1.11.4, you have a few options: - Avoid union types in your MCP tool output schema—use a single string type if possible. - If you must use union types, preprocess or normalize the schema in your own code before it reaches the workflow node, or use a code/template node to transform the output to a simple type. - If you can, upgrade to a newer Dify version where this is fixed. For schema design, always ensure the output schema's `type` is a string, not an array, and avoid constructs like `oneOf` or `anyOf` at the top level unless you know the frontend can handle them. This will prevent similar issues in the future. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/f4341cce-d8ec-4c4c-b05c-fc2ca2219284?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/f4341cce-d8ec-4c4c-b05c-fc2ca2219284?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/f4341cce-d8ec-4c4c-b05c-fc2ca2219284?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/f4341cce-d8ec-4c4c-b05c-fc2ca2219284?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f4341cce-d8ec-4c4c-b05c-fc2ca2219284?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/f4341cce-d8ec-4c4c-b05c-fc2ca2219284?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f4341cce-d8ec-4c4c-b05c-fc2ca2219284?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20error%20happens%20because%20your%20MCP%20tool%27s%20output%20schema%20uses%20a%20union%20type%20%28like%20%60type%3A%20%5B%27string%27%2C%20%27null%27%5D%60%29%2C%20but%20Dify%20v1.11.4%20doesn%27t%20normalize%20this%2C%20so%20the%20frontend%20tries%20to%20call%20string%20methods%20on%20an%20array%20or%20undefined%2C%20causing%20the%20crash.%20The%20backend%20passes%20the%20schema%20as-is%2C%20and%20the%20frontend%20expects%20%60output.type%60%20to%20always%20be%20a%20string%2C%20which%20isn%27t%20guaranteed%20with%20union%20types%20in%20JSON%20Schema.%20This%20is%20a%20known%20issue%20and%20has%20been%20reported%20in%20earlier%20versions%20as%20well%20%5B%5Bexample%5D%28https%3A//github.com/langgenius/dify/issues/21890%29%5D.%0A%0ARecent%20Dify%20versions%20added%20utility%20functions%20to%20safely%20handle%20union%20types%20and%20normalize%20schema%20types%20before%20using%20them%2C%20which%20prevents%20this%20error%20%5B%5BPR%20ref%5D%28https%3A//github.com/langgenius/dify/pull/29035%29%5D.%0A%0AFor%20v1.11.4%2C%20you%20have%20a%20few%20options%3A%0A-%20Avoid%20union%20types%20in%20your%20MCP%20tool%20output%20schema%E2%80%94use%20a%20single%20string%20type%20if%20possible.%0A-%20If%20you%20must%20use%20union%20types%2C%20preprocess%20or%20normalize%20the%20schema%20in%20your%20own%20code%20before%20it%20reaches%20the%20workflow%20node%2C%20or%20use%20a%20code/template%20node%20to%20transform%20the%20output%20to%20a%20simple%20type.%0A-%20If%20you%20can%2C%20upgrade%20to%20a%20newer%20Dify%20version%20where%20this%20is%20fixed.%0A%0AFor%20schema%20design%2C%20always%20ensure%20the%20output%20schema%27s%20%60type%60%20is%20a%20string%2C%20not%20an%20array%2C%20and%20avoid%20constructs%20like%20%60oneOf%60%20or%20%60anyOf%60%20at%20the%20top%20level%20unless%20you%20know%20the%20frontend%20can%20handle%20them.%20This%20will%20prevent%20similar%20issues%20in%20the%20future.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31773)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#22001