You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sadpandajoe (via GitHub)" <gi...@apache.org> on 2026/04/21 06:13:02 UTC
[PR] fix(mcp): surface actionable error when adhoc_filters passed to generate_chart [superset]
sadpandajoe opened a new pull request, #39507:
URL: https://github.com/apache/superset/pull/39507
### SUMMARY
When LLMs pass `adhoc_filters` (Superset's internal format) to the `generate_chart` MCP tool, the validation pipeline returns an opaque `validation_system_error` with message "An error occurred", empty details, and no suggestions — making it impossible for the LLM to self-correct.
**Root cause:** `ChartErrorBuilder.TEMPLATES` had no `"validation_error"` key, so `build_error()` fell through to defaults. Additionally, Pydantic's discriminated union error strings list all variant type names, blowing past the 200-char security truncation before the actual "did you mean 'filters'?" message.
**Fix:**
- Add `"validation_error"` template to `ChartErrorBuilder.TEMPLATES`
- Extract meaningful messages from Pydantic's `__cause__` chain before truncation (only accesses `err["msg"]`, never `err["input"]`)
- Catch config validation errors specifically with targeted `error_type`/`error_code` instead of the generic catch-all
- Add `skip_generic` flag to prevent keyword-based replacement from masking field-specific messages
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** `adhoc_filters` in config returns:
```json
{"success": false, "error_type": "validation_system_error", "message": "An error occurred", "details": "", "suggestions": [], "error_code": "VALIDATION_PIPELINE_ERROR"}
```
**After:**
```json
{"success": false, "error_type": "config_validation_error", "message": "Configuration validation failed: Unknown field 'adhoc_filters' — did you mean 'filters'?", "details": "Unknown field 'adhoc_filters' — did you mean 'filters'?", "suggestions": ["Check field names in your chart configuration", "Read the chart://configs resource for valid fields and examples", "Use the 'filters' field for structured filters (column/op/value) — do NOT use 'adhoc_filters'"], "error_code": "CONFIG_VALIDATION_ERROR"}
```
### TESTING INSTRUCTIONS
1. Call `generate_chart` with `adhoc_filters` in the config — should now return error mentioning "did you mean 'filters'?" with `CONFIG_VALIDATION_ERROR` code
2. Run: `pytest tests/unit_tests/mcp_service/chart/validation/test_pipeline_unknown_fields.py -v`
3. Run full MCP suite: `pytest tests/unit_tests/mcp_service/ -v` (1237 tests pass)
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): surface actionable error when adhoc_filters passed to generate_chart [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on PR #39507:
URL: https://github.com/apache/superset/pull/39507#issuecomment-4802688435
This is no longer needed so closing
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): surface actionable error when adhoc_filters passed to generate_chart [superset]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #39507:
URL: https://github.com/apache/superset/pull/39507#discussion_r3115452003
##########
superset/mcp_service/utils/error_builder.py:
##########
@@ -174,6 +174,15 @@ class ChartErrorBuilder:
"Modify your data selection or aggregation",
],
},
+ # Validation pipeline errors
+ "validation_error": {
+ "message": "Configuration validation failed: {reason}",
+ "details": "{reason}",
+ "suggestions": [
+ "Check field names in your chart configuration",
+ "Read the chart://configs resource for valid fields and examples",
+ ],
+ },
Review Comment:
`validation_error` template hard-codes "Configuration validation failed" but it’s also used when building `validation_system_error` in the pipeline. That can produce misleading messages for non-config/system failures (e.g. DB connectivity). Consider either (a) making the template message more generic (e.g. "Validation failed: …") or (b) introducing a separate template key for system/pipeline errors and using that in the catch-all branch.
##########
superset/mcp_service/chart/validation/pipeline.py:
##########
@@ -73,9 +73,49 @@ def _get_generic_error_message(error_str: str) -> str | None:
return None
-def _sanitize_validation_error(error: Exception) -> str:
- """SECURITY FIX: Sanitize validation errors to prevent disclosure."""
- error_str = str(error)
+def _extract_config_validation_message(error: Exception) -> str | None:
+ """Extract the meaningful validation message from a config parsing error.
+
+ Pydantic's TypeAdapter for discriminated unions produces very long type names
+ in error strings (all variant names listed), which causes the 200-char
+ truncation to cut off the actual error message. This function extracts just
+ the user-actionable part.
+ """
+ from pydantic import ValidationError as PydanticValidationError
+
+ # Check the __cause__ chain for a Pydantic ValidationError
+ cause = getattr(error, "__cause__", None)
+ if not isinstance(cause, PydanticValidationError):
+ return None
+
+ # Extract just the message parts from Pydantic's structured errors
+ messages = []
+ for err in cause.errors()[:3]:
+ msg = err.get("msg", "")
+ # Pydantic prefixes model_validator errors with "Value error, "
+ if msg.startswith("Value error, "):
+ msg = msg[len("Value error, ") :]
+ if msg:
+ messages.append(msg)
+
+ return " | ".join(messages) if messages else None
Review Comment:
The comment says “Check the __cause__ chain”, but the code only inspects a single `__cause__` level. Either traverse the chain (`while cause is not None`) to match the comment, or adjust the comment to reflect the actual behavior.
##########
tests/unit_tests/mcp_service/chart/validation/test_pipeline_unknown_fields.py:
##########
@@ -0,0 +1,110 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Regression tests for validation pipeline error surfacing.
+
+Ensures that unknown fields (like adhoc_filters) produce actionable error
+messages instead of opaque "An error occurred" responses.
+
+See: sc-103356
+"""
Review Comment:
The module docstring references `sc-103356`, which looks like an internal tracker ID and isn’t actionable for OSS contributors. Prefer linking to a public issue/PR, or describing the reproduction case in the docstring without an internal reference.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): surface actionable error when adhoc_filters passed to generate_chart [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe closed pull request #39507: fix(mcp): surface actionable error when adhoc_filters passed to generate_chart
URL: https://github.com/apache/superset/pull/39507
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): surface actionable error when adhoc_filters passed to generate_chart [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39507:
URL: https://github.com/apache/superset/pull/39507#issuecomment-4286313284
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | d666ca9187852f6da9ae6d14791d8befc5301c62 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69e7156e03b71a00080e2aec |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39507--superset-docs-preview.netlify.app](https://deploy-preview-39507--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-39507--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): surface actionable error when adhoc_filters passed to generate_chart [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39507:
URL: https://github.com/apache/superset/pull/39507#issuecomment-4286299101
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): surface actionable error when adhoc_filters passed to generate_chart [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39507:
URL: https://github.com/apache/superset/pull/39507#issuecomment-4286315092
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39507?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `26 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 54.50%. Comparing base ([`78fb096`](https://app.codecov.io/gh/apache/superset/commit/78fb09695b89b682fe9004c758142a47ce6903fb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d666ca9`](https://app.codecov.io/gh/apache/superset/commit/d666ca9187852f6da9ae6d14791d8befc5301c62?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 9 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/39507?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/mcp\_service/chart/validation/pipeline.py](https://app.codecov.io/gh/apache/superset/pull/39507?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fvalidation%2Fpipeline.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdmFsaWRhdGlvbi9waXBlbGluZS5weQ==) | 0.00% | [26 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39507?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (78fb096) and HEAD (d666ca9). Click for more details.
>
> <details><summary>HEAD has 42 uploads less than BASE</summary>
>
>| Flag | BASE (78fb096) | HEAD (d666ca9) |
>|------|------|------|
>|python|40|1|
>|hive|4|1|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #39507 +/- ##
==========================================
- Coverage 64.47% 54.50% -9.97%
==========================================
Files 2558 2560 +2
Lines 133243 133570 +327
Branches 30956 31012 +56
==========================================
- Hits 85902 72799 -13103
- Misses 45850 60436 +14586
+ Partials 1491 335 -1156
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.74% <0.00%> (-0.11%)` | :arrow_down: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.74% <0.00%> (-22.38%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/39507/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/39507?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org