Skip to content

fix(charts): exclude string helpers from post_processing operation allowlist - #43345

Open
rusackas wants to merge 1 commit into
apache:masterfrom
rusackas:fix/post-processing-operation-allowlist
Open

fix(charts): exclude string helpers from post_processing operation allowlist#43345
rusackas wants to merge 1 commit into
apache:masterfrom
rusackas:fix/post-processing-operation-allowlist

Conversation

@rusackas

Copy link
Copy Markdown
Member

SUMMARY

Follow-up from a codeant-ai-for-open-source finding on #43337: the post_processing operation allowlist (ChartDataPostProcessingOperationSchema.operation in superset/charts/schemas.py, and the dispatch guard in QueryObject.exec_post_processing) accepts escape_separator/unescape_separator as valid operation names. Those are internal str -> str helpers used by flatten, not DataFrame post-processing operations — submitting one as an operation currently either raises a confusing TypeError (the function gets called with a DataFrame instead of a string) rather than a clean validation error.

This is pre-existing on master, independent of #43337 (the old inspect.getmembers(pandas_postprocessing, inspect.isfunction) allowlist has the same gap).

Adds pandas_postprocessing.OPERATIONS, a curated list of the real DataFrame operations (excludes the two string helpers), and uses it in both the schema allowlist and the executor's dispatch guard.

While adding a test for this, found and fixed a second, related bug in the same code path: the InvalidPostProcessingError message in query_object.py used type=operation against a "...%(operation)s" format string, so hitting that branch raised a KeyError from flask_babel's gettext instead of the intended clean error. Fixed to operation=operation.

TESTING INSTRUCTIONS

pytest tests/unit_tests/charts/test_schemas.py -k post_processing_operation
pytest tests/unit_tests/queries/query_object_test.py -k post_processing

Also ran the full tests/unit_tests/pandas_postprocessing/, tests/unit_tests/charts/, and tests/unit_tests/queries/ suites locally (349 passed, 2 xfailed, unrelated) and pre-commit on the changed files.

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 the change:backend Requires changing the backend label Aug 19, 2026
@bito-code-review

bito-code-review Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8540c5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: dcbc142..dcbc142
    • superset/charts/schemas.py
    • superset/common/query_object.py
    • superset/utils/pandas_postprocessing/__init__.py
    • tests/unit_tests/charts/test_schemas.py
    • tests/unit_tests/queries/query_object_test.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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.73%. Comparing base (f9cedf8) to head (30ae1b4).

Files with missing lines Patch % Lines
superset/common/query_object.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43345   +/-   ##
=======================================
  Coverage   66.73%   66.73%           
=======================================
  Files        2876     2876           
  Lines      164218   164218           
  Branches    37890    37890           
=======================================
  Hits       109590   109590           
  Misses      52469    52469           
  Partials     2159     2159           
Flag Coverage Δ
hive 38.10% <50.00%> (ø)
mysql 57.76% <50.00%> (ø)
postgres 57.80% <50.00%> (ø)
presto 40.04% <50.00%> (ø)
python 59.18% <50.00%> (ø)
sqlite 57.43% <50.00%> (ø)
unit 100.00% <ø> (ø)

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.

@rusackas
rusackas requested review from betodealmeida, msyavuz and sadpandajoe and removed request for betodealmeida August 20, 2026 00:34
…lowlist

escape_separator/unescape_separator are str -> str helpers used internally
by flatten, not DataFrame post-processing operations. Both the schema's
validate.OneOf() choices and the query_object.py dispatch accepted them as
a post_processing operation name, so submitting one against a DataFrame
either raised a confusing TypeError (dispatch) or, previously, a KeyError
in the fallback error path (the InvalidPostProcessingError message used
type=operation against a %(operation)s format string).

Adds pandas_postprocessing.OPERATIONS, a curated list of the real
DataFrame operations, and uses it in both the schema allowlist and the
executor's dispatch guard instead of the module's broader __all__/hasattr
checks.
@rusackas
rusackas force-pushed the fix/post-processing-operation-allowlist branch from dcbc142 to 30ae1b4 Compare August 20, 2026 04:17
@bito-code-review

bito-code-review Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #18cccd

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: 30ae1b4..30ae1b4
    • superset/charts/schemas.py
    • superset/common/query_object.py
    • superset/utils/pandas_postprocessing/__init__.py
    • tests/unit_tests/charts/test_schemas.py
    • tests/unit_tests/queries/query_object_test.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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

)
]
),
validate=validate.OneOf(choices=pandas_postprocessing.OPERATIONS),

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.

Rebasing this static allowlist as written would drop master’s EXTRA_PANDAS_POSTPROCESSING_OPS extension point, so configured custom operations would start returning 400 errors. Could this be rebased to restrict only built-in operations while preserving the extra-operation validation and dispatch paths?

)
]
),
validate=validate.OneOf(choices=pandas_postprocessing.OPERATIONS),

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 checked-in OpenAPI enum still advertises escape_separator and unescape_separator, so generated clients can submit documented values that this validation now rejects. Could the OpenAPI resource be regenerated with this allowlist change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants