ITADN

MCP providers crash when inputSchema contains an unsupported parameter type

#39629OpenAnnaSuSu 创建于 23 天前
A
AnnaSuSucommented
### 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 a bug report; questions belong in Discussions. - [x] I have searched existing issues, including closed ones. - [x] I am submitting this report in English. - [x] I have kept the required bug-report fields and filled them in. ### Dify version `main` at `e35187f37626a1d3a7af5bedbebc19d40cf20cb5` (source checkout) ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce This is a source-level reproduction for an MCP schema supplied by a third-party server. 1. Have an MCP tool expose an `inputSchema` containing a property whose JSON Schema `type` is not supported by Dify, for example: ```json { "type": "object", "properties": { "query": { "type": "text" } } } ``` The same problem occurs with values such as `"String"` or a type list such as `["bogus", "null"]`. 2. Persist/register that MCP provider, then load its tools, update its credentials, or invoke one of its tools. 3. `convert_mcp_schema_to_parameter` calls `resolve_property_type`, which returns the unsupported raw type, and then passes it to `ToolParameter.ToolParameterType(prop_type)`. The conversion raises: ``` ValueError: 'text' is not a valid ToolParameter.ToolParameterType ``` Because the third-party schema is persisted as supplied, subsequent provider loads hit the same failure again. A focused regression test reproducing this path is included in #38788. ### ✔️ Expected Behavior An unsupported or malformed third-party MCP parameter type should not make the entire provider unloadable. Consistent with `resolve_property_type`'s existing fallback behavior for null, empty, cyclic, and over-depth schemas, unsupported JSON Schema type names should safely resolve to `string`. Standard JSON Schema types should remain unchanged. ### ❌ Actual Behavior The unsupported raw type reaches the `ToolParameterType` enum constructor and raises an unhandled `ValueError`. This can break provider listing/loading, credential updates, and invocation for the affected MCP provider. A proposed fix and regression tests are available in #38788. Process note: I opened the implementation PR before noticing Dify's issue-first and assignment requirement. This issue documents the failure transparently; I am happy to pause or adjust the implementation until a maintainer confirms the direction and assigns the issue.
1 条评论