aminghadersohi opened a new pull request, #38731:
URL: https://github.com/apache/superset/pull/38731

   ### TLDR
   
   When `MCP_PARSE_REQUEST_ENABLED` is `False` (flattened mode), 
`_create_flattened_wrapper` did not catch `ValidationError` from 
`model_validate(kwargs)`. A raw `ValidationError` propagating from an MCP tool 
call causes downstream serialization failures (`TypeError: encoding without a 
string argument`).
   
   ### What changed
   
   In `_create_flattened_wrapper` (both async and sync paths), wrap 
`model_validate(kwargs)` in `try/except ValidationError` and raise `ToolError` 
with a descriptive message listing the invalid/missing fields. This matches the 
existing behavior of `_create_string_parsing_wrapper`.
   
   ### Tests
   
   - Updated the existing test that documented the old buggy behavior (expected 
`ValidationError` to propagate raw) to now expect `ToolError`
   - Added a test for the missing-required-field case specifically
   
   ### Checklist
   
   - [x] Unit tests added/updated
   - [x] `ruff format` applied
   - [x] Pre-commit hooks pass


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to