Skip to content

fix(api): restore three schema fields disabled by a stray trailing comma - #43225

Merged
rusackas merged 5 commits into
apache:masterfrom
SEPURI-SAI-KRISHNA:fix/schema-tuple-fields
Sep 22, 2026
Merged

rusackas merged 5 commits into
apache:masterfrom
SEPURI-SAI-KRISHNA:fix/schema-tuple-fields

Conversation

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Contributor

SUMMARY

Three field declarations in superset/charts/schemas.py are wrapped in
parentheses with a trailing comma, which makes them one-element tuples
rather than Field instances:

groupby = (
    fields.List(
        fields.String(allow_none=False, metadata={...}),
        metadata={"minLength": 1},
        required=True,
    ),          # <-- this comma makes the whole thing a tuple
)

Marshmallow collects only Field instances into a schema, so an attribute
like this is dropped entirely: it never appears in the OpenAPI spec, and its
required=True is never applied.

The three affected declarations are each the parameter its post-processing
operation cannot run without:

Schema Field Signature
ChartDataAggregateOptionsSchema groupby aggregate(df, groupby, aggregates)
ChartDataRollingOptionsSchema columns rolling(df, rolling_type, columns, ...)
ChartDataPivotOptionsSchema index pivot(df, index, aggregates, ...)

All three are parameters with no default, and the frontend operators send all
three (pivotOperator sends index, rollingWindowOperator sends columns).
So /swagger/v1 currently documents pivot without index and aggregate
without groupby — the one option each caller must provide.

Confirmed before and after:

# master
ChartDataAggregateOptionsSchema: fields=['aggregates']
ChartDataPivotOptionsSchema:     fields=['aggregates', 'column_fill_value', 'columns', ...]   # no 'index'

# this branch
ChartDataAggregateOptionsSchema: fields=['aggregates', 'groupby']   groupby: required=True
ChartDataPivotOptionsSchema:     fields=[..., 'index', ...]         index:   required=True

No runtime behaviour changes. These schemas are documentation only —
ChartDataPostProcessingOperationSchema.options is a bare fields.Dict, so
nothing validates against them; they are registered solely for OpenAPI spec
generation. The only place any of them is .load()ed is a unit test for
rolling, whose payload does not include columns, and columns stays
optional.

I scanned the whole superset/ tree for the pattern; these three are the only
occurrences.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — the change is to the OpenAPI schema definitions.

TESTING INSTRUCTIONS

pytest tests/unit_tests/charts/test_schemas.py

Two tests are added:

test asserts
test_schema_attributes_are_fields_not_tuples no attribute on any schema in the module is a tuple wrapping a Field — a general guard against this typo recurring anywhere
test_required_post_processing_options_are_documented groupby, index and columns are present, and the two required=True ones are marked required

Re-introducing the trailing comma on any one of the three makes both fail.

To see the spec change, start Superset, open /swagger/v1 and compare the
ChartDataAggregateOptions, ChartDataRollingOptions and
ChartDataPivotOptions definitions.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

CHECKLIST

  • CI checks pass
  • Tests added/updated
  • Documentation updated
  • PR title follows conventions

@dosubot dosubot Bot added the api:charts Related to the REST endpoints of charts label Aug 15, 2026
@bito-code-review

bito-code-review Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b92497

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • tests/unit_tests/charts/test_schemas.py - 1
Review Details
  • Files reviewed - 2 · Commit Range: 4f4dda5..4f4dda5
    • superset/charts/schemas.py
    • tests/unit_tests/charts/test_schemas.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.39%. Comparing base (4c77b0b) to head (ce77fe3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43225      +/-   ##
==========================================
- Coverage   80.40%   80.39%   -0.01%     
==========================================
  Files        2932     2932              
  Lines      174525   174525              
  Branches    40548    40548              
==========================================
- Hits       140319   140313       -6     
- Misses      31537    31543       +6     
  Partials     2669     2669              
Flag Coverage Δ
hive 37.16% <100.00%> (ø)
mysql 56.60% <100.00%> (ø)
postgres 56.62% <100.00%> (ø)
presto 39.22% <100.00%> (ø)
python 84.75% <100.00%> (-0.01%) ⬇️
sqlite 56.32% <100.00%> (ø)
unit 76.35% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread superset/charts/schemas.py Resolved
Comment thread superset/charts/schemas.py Resolved
@bito-code-review

bito-code-review Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8da7ab

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 4f4dda5..d8c18e1
    • superset/charts/schemas.py
    • tests/unit_tests/charts/test_schemas.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. A stray trailing comma turning groupby = (fields.List(...),) into a one-element tuple is exactly the kind of bug that hides in plain sight: Marshmallow only collects Field instances, so all three declarations were silently dropped from their schemas — required=True never applied, never emitted to the spec. The regression test that walks every Schema subclass looking for tuple-wrapped Fields (test_schema_attributes_are_fields_not_tuples) is a good, general guard against the whole class of mistake, not just these three sites. Both bot threads were handled well too — the Dict value-typing deferral on :541 is correctly reasoned (the parent options is a bare fields.Dict, so tightening the nested schema would document, not enforce), and the minLength→Length(min=1) switch on :871 was verified empirically before landing. Reviewed at d8c18e1; nothing here blocks.

One correction, non-blocking, worth a sentence for the next reader:

validate=Length(min=1) fixes the documented constraint, not runtime enforcement. The in-code comments are precise ("the schema has to say so", "emits the correct constraint"). But the PR thread reply describing it as enforcing the bound overstates slightly. These three per-operation schemas are never .load()ed anywhere:

$ grep -rn "ChartDataPivotOptionsSchema\|ChartDataAggregateOptionsSchema\|ChartDataRollingOptionsSchema" superset/
schemas.py: <class definitions>
schemas.py:1914,1918,1919:  CHART_SCHEMAS = (...)   # api.py:309 -> openapi_spec_component_schemas

Their only consumer is OpenAPI component registration. At runtime, post_processing[].options is a bare fields.Dict (schemas.py:991), and exec_post_processing (query_object.py:554) does options = post_process.get("options", {}) then getattr(pandas_postprocessing, operation)(df, **options) — the raw dict is splatted straight into pandas. So an empty index is still rejected only by pivot() itself (pandas_postprocessing/pivot.py:117, "Pivot operation requires at least one index"), surfacing as an InvalidPostProcessingError, not a schema 400. The fix is real and strictly better than inert minLength metadata (arrays use minItems, and metadata isn't a validator) — it just corrects the emitted spec; it doesn't add a runtime gate.

Smaller notes:

  • No breaking-change risk. Because nothing loads these schemas, restoring the fields changes zero runtime behavior for existing clients. The actual request path is ChartDataQueryObjectSchema (Meta.unknown = EXCLUDE) → post_processing list → untyped options — malformed values were passed through before and still are.
  • test_pivot_and_aggregate_reject_an_empty_column_list is slightly weaker than it reads. Since it .load()s the per-op schema directly (a legitimate way to test a schema production never loads — but note it exercises a path production doesn't), and these schemas inherit Marshmallow's default unknown=RAISE, reverting the production fix makes index/groupby unknown fields, which also raises with an index/groupby message key. So the empty-rejection asserts would pass against buggy code too, for the wrong reason; only the closing non-empty positive assertion (load({"index": ["__timestamp"], ...})) actually fails on revert. The other two new tests (..._are_fields_not_tuples, ..._are_documented) fail cleanly on revert and are the load-bearing ones. Consider asserting the error message mentions the length bound to isolate the validator — optional.
  • OpenAPI snapshot: docs/static/resources/openapi.json contains these schemas but is a manually-committed artifact with no CI freshness gate (no workflow/Makefile references it; last touched by an unrelated PR). Live /swagger/v1 regenerates from source and will be correct; the static snapshot is a pre-existing, ungated staleness gap, not this PR's to fix.
  • # noqa: E501 removals are correct — de-indenting the description strings out of the tuple wrapper brings them to ≤85 chars (limit 88), so the suppressions are genuinely unneeded now.

Note: I could not run pytest in this environment (superset_core not installed) — the test analysis above is by inspection; CI is green (60 success / 9 skipped / 3 neutral, zero failures).

Comment thread superset/charts/schemas.py Resolved
Comment thread superset/charts/schemas.py Resolved
@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Contributor Author

Both questions were right, and they were right in opposite directions. thanks,
this needed the second look. Fixed and pushed.

groupby must not carry a lower bound. Confirmed exactly as you described,
and it is stronger than a hypothetical client: aggregateOperator hardcodes it.

superset-ui-chart-controls/src/operators/aggregateOperator.ts:52

return {
  operation: 'aggregate',
  options: {
    groupby: [],
    aggregates,
  },
};

That fires for every aggregation that is not LAST_VALUE or raw. And
aggregate() reads it as a deliberate branch rather than tolerating it:

if groupby:
    df_groupby = df.groupby(by=groupby)
else:
    df_groupby = df.groupby(lambda _: True)

So minItems: 1 would have published Superset's own request as invalid. The
validator is gone. required=True stays, since the parameter has no default.

rolling.columns should be required. Agreed. rolling() takes it
positionally with no default, exactly as it takes rolling_type. which this
same schema already marked required. The two were inconsistent with each other,
not just with the operation.

pivot.index keeps its bound, since pivot() does enforce it:

if not index:
    raise InvalidPostProcessingError(
        _("Pivot operation requires at least one index")
    )

Verified against the generated spec rather than the field declarations:

field required minItems
Aggregate.groupby true (none)
Rolling.columns true n/a (object)
Pivot.index true 1

The test that asserted groupby: [] is rejected encoded the bug, so it is now
test_aggregate_accepts_an_empty_groupby asserting the opposite. Making
columns required also surfaced test_chart_data_rolling_options_schema_window_range
on master, which built its payload from {"rolling_type": "mean"} alone; its
base now includes columns.

@aminghadersohi your correction is right and I have confirmed it. the only
references to these three schemas anywhere in the tree are the OpenAPI
component registration list in schemas.py and this one test file. Nothing
calls .load() on them in production, so this changes the emitted spec and
nothing else. I will reword the PR description, which implies lost runtime
validation. Your point about test_pivot_and_aggregate_reject_an_empty_column_list
being weaker than it reads is well taken and is part of why the groupby half
of it was wrong. it exercised a path no caller reaches, so nothing contradicted
it. Noted separately on docs/static/resources/openapi.json: this PR does not
regenerate it, so that snapshot still drifts.

Verified: 219 passed in tests/unit_tests/charts, ruff 0.9.7 clean, mypy 1.15.0
clean, pylint import-outside-toplevel down from 6 to 0 (the new tests' imports
are hoisted to module scope, matching the rest of the file).

@netlify

netlify Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit ce77fe3
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aab44c675a33700085e41f8
😎 Deploy Preview https://deploy-preview-43225--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #af1755

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: d8c18e1..d4deff4
    • superset/charts/schemas.py
    • tests/unit_tests/charts/test_schemas.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

"example": {"weekly_rolling_sales": "sales"},
},
),
columns = fields.Dict(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now publishes rolling.columns as an object, but PostProcessingRolling still declares it as string[]. Typed clients must choose between the exported TypeScript contract and the OpenAPI contract; an array reaches rolling() and fails at columns.keys(). Should the exported type be updated to the string-to-string mapping this operation accepts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — and I think the object (OpenAPI) side is the correct one here; it's the exported TS type that's stale, and it was already inconsistent before this PR surfaced it.

Tracing all three sides at this head:

  • Runtime rolling() takes columns: dict[str, str] (superset/utils/pandas_postprocessing/rolling.py:40) and does df.loc[:, columns.keys()] (:69). An array reaching it hits list.keys() → AttributeError, exactly as you describe.
  • What the frontend actually emits: rollingWindowOperator.ts:48 builds const columnsMap = Object.fromEntries(columns.map(col => [col, col])) and sends columns: columnsMap (:71, and :55 for cum) — a string→string object, not a string[]. So Superset's own operator already produces the mapping the OpenAPI object type describes.
  • The exported type _PostProcessingRolling.options.columns: string[] (superset-ui-core/src/query/types/PostProcessing.ts:154) is therefore the stale side — it contradicts the operator that feeds it. _PostProcessingCum (:164) has the same string[] while the operator emits columnsMap for cum too.

This PR didn't introduce the divergence: columns was always fields.Dict; the stray-tuple bug had dropped it from the published spec entirely, so the conflict was invisible until the field was restored. The OpenAPI contract now matches both rolling()'s signature and the operator's real output.

So I don't think anything needs to change in this Python-only PR — the correct follow-up is a separate frontend change fixing PostProcessingRolling (and PostProcessingCum) to Record<string, string>. Leaving that call to you and the author.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks both, agreed with @aminghadersohi's read, and with keeping it out of this PR.

I'd reached the same conclusion independently: the OpenAPI object is correct and the exported TypeScript type is the stale side. Two details that I think settle it beyond the signature trace:

Every assertion already in the repo expects an object, so the mapping isn't a new contract, it's the one that was always in force:

rollingWindowOperator.test.ts        columns: { 'count(*)': 'count(*)', ... }
MixedTimeseries/buildQuery.test.ts   columns: { count: 'count', ... }

The only string[] anywhere is the ROLLING_RULE fixture in PostProcessing.test.ts, which uses one solely because the type asks for it.

And the reason a contradiction this direct never failed the build: columns.map(col => [col, col]) widens each pair to (string | undefined)[] rather than a tuple, which selects the untyped Object.fromEntries overload —

fromEntries<T = any>(entries: Iterable<readonly [PropertyKey, T]>): { [k: string]: T };
fromEntries(entries: Iterable<readonly any[]>): any;   // <- selected

so columnsMap is any and assigns to string[] silently. Forcing the tuple surfaces the real error:

error TS2322: Type 'string[]' is not assignable to type 'Record<string, string>'.
  Index signature for type 'string' is missing in type 'string[]'.

So this PR stays Python-only as it stands, and I'll send the frontend fix separately. I'll include diff alongside rolling and cum, diff() takes columns: dict[str, str] and does df[columns.keys()] too, so _PostProcessingDiff carries the identical mismatch even though no operator emits it today.

@sadpandajoe the two earlier threads are addressed at this head as well, whenever you get a chance to look.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separate fix is still open, so merging this head first would publish an object in OpenAPI while the exported client type still says string[]. Can #43589 merge first, or can this PR include the type change, so the two public contracts cannot ship out of order?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair concern, and I would rather not fix it by widening this PR.

The frontend change is #43589, and it is already approved and mergeable -- it retypes
columns from string[] to Record<string, string> in
superset-ui-core/src/query/types/PostProcessing.ts for the rolling, diff and cum
types. So the ordering you are asking for is available without any new work: merge
#43589 first, then this one, and the two contracts never disagree in a released state.

For what it is worth the window is narrower than it looks. Master publishes no
columns property on ChartDataRollingOptionsSchema at all today -- the trailing
comma dropped the field before apispec ever saw it -- so the spec is currently silent
rather than wrong. Merging this first would move it from silent to contradicting the
exported type, which I agree is worse than silence, hence the ordering.

Happy to hold this PR until #43589 lands if that is easiest for you. I would rather not
pull the TypeScript change in here, since it would put a frontend edit in a PR that is
otherwise Python-only and would make it harder to revert either half independently.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Contributor Author

Frontend follow-up is up as #43589, rolling, cum and diff all moved to Record<string, string>, along with the three fixtures in PostProcessing.test.ts that were using arrays.

Worth noting the one red check there is lint-frontend, which looks unrelated to the change: the 94 errors are all import(no-named-as-default) in files the PR doesn't touch (src/SqlLab/…, src/features/datasets/…), and neither changed file appears in the output. The same 94/1863 counts show up on unrelated PRs, and the failing runs finish in roughly a third of the time of the passing ones, so npm i looks to be short-circuiting and leaving oxlint unable to resolve imports. Running oxlint against the two changed files directly reports nothing.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 3, 2026
@github-actions github-actions Bot added doc Namespace | Anything related to documentation and removed requires:rebase Requires rebasing on top of current master labels Sep 5, 2026
@bito-code-review

bito-code-review Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #97a5f9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 427eabb..7453682
    • superset/charts/schemas.py
    • tests/unit_tests/charts/test_schemas.py
  • Files skipped - 1
    • docs/static/resources/openapi.json - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round-3 review at 7453682e58da. The gate on this PR is @sadpandajoe — his three threads are the open items, and whether they are satisfied is his call, not mine. What follows is measurement only, offered to save him time; I am not resolving anything or crediting his threads as closed.

I re-verified the three claims his threads turn on against the runtime at this head, and mutation-tested every new guard.

His three threads, measured against the code at this head

1. groupby should not carry minItems: 1 (thread on Aggregate.groupby, now outdated)
Runtime agrees with him. aggregate() branches on the empty case explicitly — if groupby: df.groupby(by=groupby) else: df.groupby(lambda _: True) (superset/utils/pandas_postprocessing/aggregate.py:42-46) — so groupby: [] is the global-aggregation request, not a malformed one. aggregateOperator.ts:54 emits groupby: [] verbatim. At this head the field carries required=True and no validator, and openapi.json publishes groupby as a required array with no minItems. Matches what he asked for.

2. rolling.columns should be required (thread live at line 594)
Runtime agrees. rolling() takes columns: dict[str, str] positionally with no default (superset/utils/pandas_postprocessing/rolling.py:37-46) and immediately does df.loc[:, columns.keys()] (:69). At this head columns carries required=True and openapi.json lists columns in Rolling.required alongside rolling_type and window. Matches.

3. rolling.columns typed as object vs. PostProcessingRolling: string[] (thread live at line 594)
This one is a genuine cross-language divergence and it is not resolved by this PR — by design, as he and the author discussed. The OpenAPI object side matches both rolling()'s signature and what rollingWindowOperator.ts actually emits; the exported TS type is the stale side, and it was stale before this PR. The PR stays Python-only and the author has committed to a separate frontend change. Whether that is an acceptable split is @sadpandajoe's call.

Mutation testing — the new guards are not vacuous

I reverted each fix in superset/charts/schemas.py one at a time, confirmed the mutation landed, and re-ran tests/unit_tests/charts/test_schemas.py (43 passed clean):

Mutation (symbol) Result
Re-wrap ChartDataPivotOptionsSchema.index in the original 1-tuple 3 fail, incl. test_schema_attributes_are_fields_not_tuples
Drop validate=Length(min=1) from ...PivotOptionsSchema.index test_pivot_rejects_an_empty_index fails
Drop required=True from ...RollingOptionsSchema.columns test_required_post_processing_options_are_documented fails
Add validate=Length(min=1) to ...AggregateOptionsSchema.groupby test_aggregate_accepts_an_empty_groupby fails

Every guard kills its mutant. The tuple-detector genuinely catches the original bug rather than merely asserting present-state.

I also ran a static AST scan for the same stray-comma pattern across all of superset/: no other field declarations are wrapped in a tuple, so the fix is complete in scope.

openapi.json matches the schema changes exactly — the three added entries and nothing else, no unrelated regeneration drift.

One non-blocking observation (pre-existing; entirely optional)

ChartDataPivotOptionsSchema.aggregates (superset/charts/schemas.py:966) has the same shape as the rolling.columns gap @sadpandajoe asked to close in thread 2: pivot() raises "Pivot operation must include at least one aggregate" (pivot.py:243-245), but the schema leaves aggregates optional. Measured under app context at this head:

required(aggregates) = False
load {"index": ["a"]}                   -> {'index': ['a']}      # aggregates omitted, accepted
load {"index": ["a"], "aggregates": {}} -> accepted

Both are payloads the published spec permits and the operation rejects. This is pre-existing and untouched by this PR — aggregates was never one of the tuple-disabled fields — so I am explicitly not asking for it here. Flagging it only because it is the exact class of defect this PR is closing, in case @sadpandajoe wants it pulled into scope rather than left for a follow-up.

Context worth stating plainly

ChartDataPostProcessingOperationSchema.options is fields.Dict (schemas.py:1080) — untyped. These per-operation option schemas are therefore documentation/spec artifacts, not request-time validators; nothing here changes what the API accepts at runtime. That makes the blast radius of this PR small, and it is also why the minLength-as-metadata bug could sit unnoticed. It does not diminish the fix — a published contract that contradicts the operation is worth correcting — but it should temper how the change is described.

CI: re-derived from statusCheckRollup taking the latest run per leg name (74 raw entries collapse to 60 unique) — 49 SUCCESS, 9 SKIPPED, 2 NEUTRAL, zero failures.

Deferring to @sadpandajoe on all three of his threads.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Contributor Author

Thanks for the round-3 measurement, and for being explicit that the three open threads are @sadpandajoe's to close rather than yours. Nothing for me to action there.

On your non-blocking observation about ChartDataPivotOptionsSchema.aggregates: I ran it, and I agree it should not go into this PR. But it is worth recording that the defect is both wider and more severe than the way it was flagged, because that changes how a follow-up should be scoped.

It is not one field. I swept all twelve ChartData*OptionsSchema classes, comparing each declared field against the operation's signature, and asked which parameters have no default while the field is optional:

Schema Field(s)
ChartDataAggregateOptionsSchema aggregates
ChartDataBoxplotOptionsSchema groupby, metrics
ChartDataPivotOptionsSchema aggregates

Four fields, three schemas. Every other option schema is consistent with its operation.

The omitted-key case is a 500, not a 400. pivot()'s "Pivot operation must include at least one aggregate" guard never runs, because the call never gets that far. exec_post_processing dispatches as func(df, **post_process.get("options", {})) (superset/common/query_object.py:668) with no try, so a missing key fails at binding time:

aggregate  {"groupby": ["g"]}         -> TypeError: aggregate() missing 1 required positional argument: 'aggregates'
pivot      {"index": ["g"]}           -> TypeError: pivot() missing 1 required positional argument: 'aggregates'
boxplot    {"whisker_type": "tukey"}  -> TypeError: boxplot() missing 2 required positional arguments: 'groupby' and 'metrics'

A bare TypeError is not an InvalidPostProcessingError, so these surface as an unhandled 500 rather than a validation error. The published spec advertises four payloads that crash the chart-data endpoint.

The empty-value case splits three ways, which is why required=True alone is not the whole fix:

pivot      {"index": ["g"], "aggregates": {}}         -> InvalidPostProcessingError  (correct, a clean 400)
aggregate  {"groupby": ["g"], "aggregates": {}}       -> TypeError: Must provide 'func' or tuples of '(column, aggfunc)
boxplot    {"groupby": [], "metrics": [], ...}        -> TypeError: Must provide 'func' or tuples of '(column, aggfunc)

Pivot already handles empty correctly, your minItems reasoning on groupby applies here in reverse, and its guard is the model the other two lack. Aggregate and boxplot leak a raw pandas message instead.

Marking them required is safe for existing charts. Every frontend operator that emits these operations sets the keys unconditionally: aggregateOperator.ts:55, pivotOperator.ts:48, timeComparePivotOperator.ts:52, and
boxplotOperator.ts:60-61 (both via ensureIsArray, so possibly empty but never absent). No saved query_context that the frontend produced can be relying on the omission.

So: agreed, out of scope here, and I am not asking for it to be pulled in. I will take it as a separate change, required=True on the four fields for the omitted case, and a decision on the empty case for aggregate and boxplot, rather than leaving it as a loose end.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 9, 2026
SEPURI-SAI-KRISHNA and others added 3 commits September 10, 2026 09:11
Review caught that un-tupling the three field declarations was right but
the constraints attached to them were not uniform.

`groupby` must not carry a lower bound. `aggregate()` reads an empty
groupby as the global-aggregation case, grouping the frame as a whole
via `df.groupby(lambda _: True)`, and the frontend's `aggregateOperator`
emits `groupby: []` verbatim for every aggregation that is not
LAST_VALUE or raw. Publishing `minItems: 1` would have documented
Superset's own request as invalid. The parameter still has no default,
so it stays required.

`rolling()` takes `columns` positionally with no default, exactly as it
takes `rolling_type`, which this schema already marked required. Mark
`columns` required too, so the spec matches the operation contract
instead of describing a payload that fails when invoked.

`pivot.index` keeps its lower bound: pivot() raises "Pivot operation
requires at least one index" on an empty list, so minItems: 1 is what
the operation actually enforces.

Also hoist the new tests' imports to module scope, matching the rest of
the file and clearing the import-outside-toplevel warnings the previous
commit introduced.

Found by sadpandajoe in review.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 10, 2026
@bito-code-review

bito-code-review Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #fc1c07

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 144c778..881645f
    • superset/charts/schemas.py
    • tests/unit_tests/charts/test_schemas.py
  • Files skipped - 1
    • docs/static/resources/openapi.json - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase-only push: the PR's own diff at 881645f2 is byte-identical to 7453682e, and both upstream Prophet changes to these files survived. 50/50 pass, every guard kills its mutant, CI 61/61 clean.

@sadpandajoe's three threads are still open and remain his to close.

Comment thread superset/charts/schemas.py Resolved
…lumns

`rolling()` selects `df.loc[:, columns.keys()]`, so the keys are the source
columns and must already exist on the frame. The example inverted that,
mapping `weekly_rolling_sales` to `sales`, which asks the operation to read a
source column no client would have and rejects the request before the target
column can be created. It also contradicted the field's own description one
line above, which states the mapping runs source to target.

The field was disabled by a trailing comma before this PR, so it never reached
the published spec and the example had no way to mislead anyone. Restoring the
field is what exposes it, so the correction belongs here.

Found by sadpandajoe in review.
@bito-code-review

bito-code-review Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b76ed4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 881645f..b46dada
    • superset/charts/schemas.py
  • Files skipped - 1
    • docs/static/resources/openapi.json - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on the trailing comma, and I like that you traced exactly which post-processing operator depends on each dropped field. LGTM, will get this merged once CI's green.

@rusackas

Copy link
Copy Markdown
Member

...and holler if you need a hand with the rebase, but leaving that to you for now.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 17, 2026
…fields

# Conflicts:
#	tests/unit_tests/charts/test_schemas.py
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 17, 2026
@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Contributor Author

Thanks! Merged master in and regenerated openapi.json; the conflict with #43206 was just both PRs appending tests to test_schemas.py, and all 51 tests pass with both sets together. CI is green now.

@rusackas
rusackas merged commit c6d0890 into apache:master Sep 22, 2026
76 checks passed
villebro pushed a commit that referenced this pull request Sep 22, 2026
…mma (#43225)

Co-authored-by: Claude Opus 5 <[email protected]>
(cherry picked from commit c6d0890)
@SEPURI-SAI-KRISHNA
SEPURI-SAI-KRISHNA deleted the fix/schema-tuple-fields branch November 21, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:charts Related to the REST endpoints of charts doc Namespace | Anything related to documentation size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants