fix(mcp): handle all chart types in column normalization and reject adhoc_filters#39283
Draft
sadpandajoe wants to merge 2 commits intomasterfrom
Draft
fix(mcp): handle all chart types in column normalization and reject adhoc_filters#39283sadpandajoe wants to merge 2 commits intomasterfrom
sadpandajoe wants to merge 2 commits intomasterfrom
Conversation
…dhoc_filters Two fixes for sc-103356: 1. normalize_column_names() previously fell through to TableChartConfig.model_validate() for non-XY/Table chart types (pie, pivot_table, mixed_timeseries, etc.), which raised a Pydantic ValidationError due to discriminator mismatch. That exception wasn't caught by the narrow except-tuple in the pipeline, surfacing as an opaque validation_system_error. Now each chart type is reconstructed with its own model, and the except clause catches all exceptions. 2. When adhoc_filters is passed in config, it was silently dropped by Pydantic's extra="ignore". Now schema_validator detects it early and returns a clear error with guidance to use the 'filters' field instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #39283 +/- ##
==========================================
- Coverage 64.42% 64.41% -0.01%
==========================================
Files 2553 2553
Lines 132588 132602 +14
Branches 30758 30765 +7
==========================================
Hits 85416 85416
- Misses 45686 45700 +14
Partials 1486 1486
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…add missing tests - Remove unused NORMALIZATION_EXCEPTIONS constant from dataset_validator.py - Replace broad `except Exception` with explicit exception tuple including PydanticValidationError in pipeline.py normalization handler - Add smoke tests for HandlebarsChartConfig and BigNumberChartConfig normalization - Add handlebars and big_number to adhoc_filters detection parametrize list Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Two fixes for MCP
generate_chartreturning an opaquevalidation_system_error.Fix 1: Column normalization for all chart types
normalize_column_names()previously fell through toTableChartConfig.model_validate()for non-XY/Table chart types (pie, pivot_table, mixed_timeseries, handlebars, big_number), which raised a PydanticValidationErrordue to discriminator mismatch. That exception wasn't caught by the narrowexcept-tuple inValidationPipeline._normalize_column_namesand surfaced to users as an opaquevalidation_system_error.Now each chart type is reconstructed with its own model class, and the
exceptclause uses broadExceptionto catch any unexpected errors during normalization.Fix 2: Reject
adhoc_filterswith a clear errorWhen
adhoc_filters(Superset's internal format) was passed in config, it was silently dropped by Pydantic'sextra="ignore", giving the caller no indication that filters were not applied. Nowschema_validatordetects it early and returns a clearUNSUPPORTED_ADHOC_FILTERSerror with guidance to use the simplifiedfiltersfield instead.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only change in MCP service validation.
TESTING INSTRUCTIONS
Run the new unit tests:
Verify that existing tests still pass:
Manual verification via MCP:
generate_chartwith a pie chart config → should no longer returnvalidation_system_errorgenerate_chartwithadhoc_filtersin config → should return clearUNSUPPORTED_ADHOC_FILTERSerror with suggestionsADDITIONAL INFORMATION