You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "msyavuz (via GitHub)" <gi...@apache.org> on 2026/04/20 10:19:15 UTC

[PR] fix(mcp): surface structured errors for generate_chart validation failures [superset]

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

   ### SUMMARY
   
   Several `generate_chart` validation failures were surfacing as a generic `VALIDATION_PIPELINE_ERROR` with an empty `message` / `details` / `suggestions` body, leaving MCP clients with no actionable information to self-correct.
   
   Affected scenarios:
   - `big_number` + `compare_lag` without `show_trendline`
   - Unknown / misspelled config fields for any chart type
   - Any post-schema-validation failure raised by a Pydantic `model_validator`
   - `get_chart_type_schema` called with an unknown `chart_type`
   
   **Root cause:** `parse_chart_config()` wraps every `PydanticValidationError` in a bare `ValueError` + hint, which is then caught by the pipeline's broad `except Exception`. That catch-all built an error via `ChartErrorBuilder.build_error(template_key="validation_error", ...)`, but `"validation_error"` did not exist in `ChartErrorBuilder.TEMPLATES`, so the formatter fell back to `"An error occurred"` and empty suggestions.
   
   **Fix:**
   - Wrap `parse_chart_config` in a dedicated `except ValueError`, walk `__cause__` to recover the original `PydanticValidationError`, and build a `CHART_CONFIG_VALIDATION_ERROR` that carries the real field path, the real Pydantic message, and chart-type-specific suggestions (e.g. "call `get_chart_type_schema(chart_type='big_number')`").
   - Add the missing `validation_error` template so the outer catch-all always produces a populated message/details/suggestions body even for unexpected exceptions.
   - Change `get_chart_type_schema` to return a structured error dict (`error_type`, `message`, `details`, `suggestions`, `error_code`) when given an unknown `chart_type`, instead of a bare `{error, valid_chart_types, hint}` dict.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before** (compare_lag without show_trendline):
   ```
   error_type: validation_system_error
   message:    "An error occurred"
   details:    ""
   suggestions: []
   error_code: VALIDATION_PIPELINE_ERROR
   ```
   
   **After**:
   ```
   error_type: chart_config_validation_error
   message:    "compare_lag requires show_trendline=True. Period comparison is only available for trendline charts."
   details:    (same message)
   suggestions:
     - "Inspect the 'big_number' schema with get_chart_type_schema(chart_type='big_number')"
     - "Review the error message above — it identifies the offending field"
     - "Call get_chart_type_schema with your chart_type to see valid fields"
     - "Check that field names match exactly (case-sensitive)"
   error_code: CHART_CONFIG_VALIDATION_ERROR
   ```
   
   ### TESTING INSTRUCTIONS
   
   1. `pytest tests/unit_tests/mcp_service/chart/validation/test_pipeline_structured_errors.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py -v`
   2. `pytest tests/unit_tests/mcp_service/chart/ -q` (546 tests, all pass)
   3. Call `generate_chart` with each affected payload (`compare_lag` without `show_trendline`, unknown field, etc.) and verify the response now includes populated `error_type` / `message` / `suggestions`.
   4. Call `get_chart_type_schema` with an unknown `chart_type` (e.g. `"foobar"`) and verify the `error` key now contains a structured object with `error_type="invalid_chart_type"` and suggestions listing valid types.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] 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 structured errors for generate_chart validation failures [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz merged PR #39484:
URL: https://github.com/apache/superset/pull/39484


-- 
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 structured errors for generate_chart validation failures [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39484:
URL: https://github.com/apache/superset/pull/39484#issuecomment-4279831516

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39484?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 `37 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 55.38%. Comparing base ([`fbd0621`](https://app.codecov.io/gh/apache/superset/commit/fbd062165e2362fb6e6c5d1926c82cd78c12b003?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`5eb029d`](https://app.codecov.io/gh/apache/superset/commit/5eb029d8854e717e801c8e57f5473ee2a8b9d5af?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/39484?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/39484?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% | [36 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39484?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...et/mcp\_service/chart/tool/get\_chart\_type\_schema.py](https://app.codecov.io/gh/apache/superset/pull/39484?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fget_chart_type_schema.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9nZXRfY2hhcnRfdHlwZV9zY2hlbWEucHk=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39484?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #39484      +/-   ##
   ==========================================
   - Coverage   64.49%   55.38%   -9.12%     
   ==========================================
     Files        2557     2557              
     Lines      133191   133227      +36     
     Branches    30935    30941       +6     
   ==========================================
   - Hits        85897    73783   -12114     
   - Misses      45804    58792   +12988     
   + Partials     1490      652     -838     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/39484/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/39484/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/39484/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/39484/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/39484/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.63% <0.00%> (-0.03%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/39484/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.63% <0.00%> (-20.53%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/39484/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/39484/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/39484?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


Re: [PR] fix(mcp): surface structured errors for generate_chart validation failures [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39484:
URL: https://github.com/apache/superset/pull/39484#issuecomment-4333554476

   **Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it


-- 
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 structured errors for generate_chart validation failures [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39484:
URL: https://github.com/apache/superset/pull/39484#issuecomment-4333200433

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 5eb029d8854e717e801c8e57f5473ee2a8b9d5af |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69f060aaeb791c00087fd5b0 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39484--superset-docs-preview.netlify.app](https://deploy-preview-39484--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM5NDg0LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.VFTcmo8QiM4TkZK6jHvCHBH9wsde2eV-XP2yaCoLcJA)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-39484--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 structured errors for generate_chart validation failures [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39484:
URL: https://github.com/apache/superset/pull/39484#issuecomment-4279808847

   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