Repository navigation
fix(table): exclude metricSqlExpressions from ownState→extra_form_data spread - #41555
Conversation
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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-742When `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-32The 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
| | Record<string, string> | ||
| | undefined) ?? {}); | ||
| Object.entries(datasourceExpressions).forEach(([label, expression]) => { | ||
| if (!sqlExpressionMap[label]) { | ||
| sqlExpressionMap[label] = expression; | ||
| } | ||
| }); |
There was a problem hiding this comment.
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
| | 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]>
|
Bito Automatic Review Skipped – PR Already Merged |
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]>
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]>
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]>
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]>
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, allownStatefields (exceptclientView) are spread intoform_data.extra_form_data:When the AG Grid plugin wrote
metricSqlExpressionsintoownState(to pass datasource-level SQL expressions tobuildQueryfor filter resolution), it landed inextra_form_dataand was then serialised intoparamson save.Fix:
Add
metricSqlExpressionsto theomitlist so it is excluded from theownState → extra_form_dataspread:metricSqlExpressionsremains inownStatein memory (it is never serialised to params after this omit).buildQuerycontinues to read it fromownStateexactly as before — no behaviour change, no lifecycle coupling.What this does not change:
buildQuery— readsownState.metricSqlExpressionsas beforeownStateshape — no plugin changes neededmetricSqlExpressionsin 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
paramsfield in theslicestable no longer containsmetricSqlExpressionsADDITIONAL INFORMATION