Skip to content

fix(table): exclude metricSqlExpressions from ownState→extra_form_data spread - #41555

Merged
Antonio-RiveroMartnez merged 1 commit into
apache:masterfrom
fitzee:bug111864
Jun 29, 2026
Merged

Antonio-RiveroMartnez merged 1 commit into
apache:masterfrom
fitzee:bug111864

Conversation

@fitzee

@fitzee fitzee commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

AG Grid table plugin was serialising metricSqlExpressions — a full mapping of every datasource metric and calculated column to its SQL expression — into chart params on save, causing 927 MB param payloads on large datasources.

Root cause:

In ExploreViewContainer/mapStateToProps, all ownState fields (except clientView) are spread into form_data.extra_form_data:

const ownStateForQuery = omit(dataMask[slice_id]?.ownState, ['clientView']);
form_data.extra_form_data = mergeExtraFormData({ ...form_data.extra_form_data }, { ...ownStateForQuery });

When the AG Grid plugin wrote metricSqlExpressions into ownState (to pass datasource-level SQL expressions to buildQuery for filter resolution), it landed in extra_form_data and was then serialised into params on save.

Fix:

Add metricSqlExpressions to the omit list so it is excluded from the ownState → extra_form_data spread:

const ownStateForQuery = omit(dataMask[slice_id]?.ownState, [
  'clientView',
  'metricSqlExpressions',
]);

metricSqlExpressions remains in ownState in memory (it is never serialised to params after this omit). buildQuery continues to read it from ownState exactly as before — no behaviour change, no lifecycle coupling.

What this does not change:

  • Filter resolution in buildQuery — reads ownState.metricSqlExpressions as before
  • The AG Grid plugin's ownState shape — no plugin changes needed
  • Backward compatibility — existing saved charts with metricSqlExpressions in params will continue to work (those fields are simply ignored on load)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — params size fix, no visual change.

TESTING INSTRUCTIONS

  1. Open a chart using the AG Grid table plugin with a datasource that has many saved metrics (SQL expressions)
  2. Apply a column filter — verify the filter works correctly (metric label → SQL resolution still works)
  3. Save the chart — verify the params field in the slices table no longer contains metricSqlExpressions

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

@dosubot dosubot Bot added change:frontend Requires changing the frontend explore:performance Related to performance of Explore viz:charts:table Related to the Table chart labels Jun 29, 2026
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit f3f8e27
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a42f049573c8e000843b1ce
😎 Deploy Preview https://deploy-preview-41555--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.

@codecov

codecov Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.60%. Comparing base (9380d83) to head (bbb59a1).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41555      +/-   ##
==========================================
- Coverage   64.60%   64.60%   -0.01%     
==========================================
  Files        2664     2664              
  Lines      146430   146430              
  Branches    33858    33858              
==========================================
- Hits        94603    94597       -6     
- Misses      50110    50116       +6     
  Partials     1717     1717              
Flag Coverage Δ
javascript 69.11% <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.

@bito-code-review bito-code-review Bot 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.

Code Review Agent Run #1aba4c

Actionable Suggestions - 1
  • superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts - 1
    • CWE-1321: Object injection sink vulnerability · Line 525-531
Additional Suggestions - 2
  • superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts - 1
    • CWE-20: Cache Key Collision on Undefined slice_id · Line 742-742
      When `slice_id` is undefined, `slice_id ?? 0` causes all such charts to share cache key `0`. Multiple charts without slice_id would overwrite each other's expressions, causing `buildQuery` to resolve filters with the wrong SQL expression. This could produce incorrect query results or SQL errors. The backward compatibility fallback in `buildQuery` (lines 523-526) mitigates but doesn't prevent the collision. Consider tracking charts without slice_id separately or using formData as a secondary cache key. ([CWE-20](https://cwe.mitre.org/data/definitions/20.html))
  • superset-frontend/plugins/plugin-chart-ag-grid-table/src/cache.ts - 1
    • Missing cache lifecycle docs · Line 29-32
      The cache comment (line 27) describes the bloat fix but omits lifecycle expectations: when are entries evicted in production? The Map grows unbounded — entries from deleted charts or chart renames are never removed. Contrast with `buildQuery.test.ts` which manually calls `.delete()` in `afterEach`, implying no automatic cleanup exists.
Review Details
  • Files reviewed - 8 · Commit Range: f3f8e27..f3f8e27
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTableChart.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/cache.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/types.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/AgGridTableChart.test.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts
    • superset-frontend/src/explore/components/ExploreViewContainer/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ 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

Comment on lines +525 to +531
| Record<string, string>
| undefined) ?? {});
Object.entries(datasourceExpressions).forEach(([label, expression]) => {
if (!sqlExpressionMap[label]) {
sqlExpressionMap[label] = expression;
}
});

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.

CWE-1321: Object injection sink vulnerability

Lines 528-529 have object injection sink (CWE-1321): label from Object.entries() is used directly as object key without sanitization, enabling prototype pollution if datasourceExpressions is attacker-controlled.

Code suggestion
Check the AI-generated fix before applying
Suggested change
| Record<string, string>
| undefined) ?? {});
Object.entries(datasourceExpressions).forEach(([label, expression]) => {
if (!sqlExpressionMap[label]) {
sqlExpressionMap[label] = expression;
}
});
| Record<string, string>
| undefined) ?? {});
// Blocklist of dangerous property names that could cause prototype pollution
const blockedProps = new Set(['__proto__', 'constructor', 'prototype']);
Object.entries(datasourceExpressions).forEach(([label, expression]) => {
if (
!blockedProps.has(label) &&
Object.prototype.hasOwnProperty.call(sqlExpressionMap, label)
) {
// Do nothing, property already exists
} else if (!blockedProps.has(label)) {
sqlExpressionMap[label] = expression;
}
});

Code Review Run #1aba4c


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

…a spread

metricSqlExpressions (a full datasource metric→SQL map) was being spread from
chart ownState into extra_form_data in ExploreViewContainer, then serialised
into chart params on save. On large datasources this caused 927 MB param payloads.

The fix is a single targeted omit: metricSqlExpressions is excluded from the
ownState→extra_form_data merge, so it is never written to params. It remains
in ownState in memory, where buildQuery already reads it — no behaviour change,
no lifecycle coupling.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions github-actions Bot removed the plugins label Jun 29, 2026
@fitzee fitzee changed the title fix(table): stop persisting metricSqlExpressions in ownState to prevent params bloat fix(table): exclude metricSqlExpressions from ownState→extra_form_data spread Jun 29, 2026
@Antonio-RiveroMartnez
Antonio-RiveroMartnez merged commit 4a32e0b into apache:master Jun 29, 2026
72 of 73 checks passed
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

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.
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

fitzee added a commit to fitzee/superset that referenced this pull request Jul 1, 2026
PR apache#41555 stopped new writes of metricSqlExpressions into extra_form_data,
but existing slices saved before that fix still carry the bloated data in
their params and query_context columns.

This Alembic migration strips metricSqlExpressions from
extra_form_data in both columns for all ag_grid_table slices, so
existing charts no longer load hundreds of MB of runtime-derived SQL
expressions on every dashboard request.

The field is regenerated automatically by transformProps on the next
chart render and does not need to be restored on downgrade.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
fitzee added a commit to fitzee/superset that referenced this pull request Jul 2, 2026
PR apache#41555 stopped new writes of metricSqlExpressions into extra_form_data,
but existing slices saved before that fix still carry the bloated data in
their params and query_context columns.

This Alembic migration strips metricSqlExpressions from
extra_form_data in both columns for all ag_grid_table slices, so
existing charts no longer load hundreds of MB of runtime-derived SQL
expressions on every dashboard request.

The field is regenerated automatically by transformProps on the next
chart render and does not need to be restored on downgrade.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
fitzee added a commit to fitzee/superset that referenced this pull request Jul 3, 2026
PR apache#41555 stopped new writes of metricSqlExpressions into extra_form_data,
but existing slices saved before that fix still carry the bloated data in
their params and query_context columns.

This Alembic migration strips metricSqlExpressions from
extra_form_data in both columns for all ag_grid_table slices, so
existing charts no longer load hundreds of MB of runtime-derived SQL
expressions on every dashboard request.

The field is regenerated automatically by transformProps on the next
chart render and does not need to be restored on downgrade.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
fitzee added a commit to fitzee/superset that referenced this pull request Jul 14, 2026
PR apache#41555 stopped new writes of metricSqlExpressions into extra_form_data,
but existing slices saved before that fix still carry the bloated data in
their params and query_context columns.

This Alembic migration strips metricSqlExpressions from
extra_form_data in both columns for all ag_grid_table slices, so
existing charts no longer load hundreds of MB of runtime-derived SQL
expressions on every dashboard request.

The field is regenerated automatically by transformProps on the next
chart render and does not need to be restored on downgrade.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend explore:performance Related to performance of Explore size/XS viz:charts:table Related to the Table chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants