goingforstudying-ctrl opened a new pull request, #40746:
URL: https://github.com/apache/superset/pull/40746
Fixes #40733
## Problem
Multiple MCP tools (`get_dataset_info`, `get_chart_info`, `generate_chart`)
fail with a Pydantic validation error when the calling user has Superset roles
assigned:
```
2 validation errors for UserInfo
roles.0
Input should be a valid string [type=string_type, input_value=Admin,
input_type=Role]
```
The `UserInfo` model uses `from_attributes=True`, so Pydantic maps
`user.roles` directly. With the SQLAlchemy ORM, `roles` returns `Role`
objects—not strings—causing serialization to fail.
## Fix
Add a `field_validator("roles", mode=before)` to `UserInfo` that coerces
each item:
- If already a `str`, keep it
- If it has a `.name` attribute (Role ORM object), extract `str(item.name)`
This is idempotent and backward-compatible.
## Impact
- Fixes false-negative responses from MCP tools
- Prevents retry storms from LLM clients that interpret the error as a
failure
- `generate_chart` with `save_chart=true` no longer silently saves while
reporting failure
--
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]