Skip to content

fix(typing): pass str dataset ids in tree table guest RLS rules - #46668

Merged
hainenber merged 1 commit into
masterfrom
ultraset-tree-table-guest-tests-dataset-typeddict-int
Nov 28, 2026
Merged

hainenber merged 1 commit into
masterfrom
ultraset-tree-table-guest-tests-dataset-typeddict-int

Conversation

@sadpandajoe

Copy link
Copy Markdown
Member

SUMMARY

The scheduled full-tree mypy (main) pre-commit check on master fails with two typeddict-item errors in tests/integration_tests/charts/data/tree_table_guest_tests.py (lines 704 and 841). They came in with #46490 (e81334c), the only commit that touches this file.

Root cause: both tests call security_manager.create_guest_access_token(..., rls=[{"dataset": self.table.id, ...}]). The rls argument is list[GuestTokenRlsRule], and GuestTokenRlsRule.dataset is typed Optional[str] (superset/security/guest_token.py:266), but self.table.id is an int. SqlaTable inherits id: int from superset_core's CoreDataset. Because pyproject.toml sets follow_imports = "skip" for superset_core.*, a scoped mypy run (such as the per-PR changed-files run) resolves SqlaTable.id as Any and passes. Only the full-tree run, which lists superset-core/src as an input, resolves it as int and reports the mismatch.

Fix: pass str(self.table.id) in both rules, as the other typed callers already do (for example row_level_security_tests.py uses str(dataset.id)). Runtime behaviour is unchanged: get_guest_rls_filters compares str(rule.get("dataset")) == str(dataset.id), and the other consumers only check truthiness.

TESTING INSTRUCTIONS

  1. Check out this branch and run pre-commit run mypy --all-files.
  2. Confirm no errors are reported for tests/integration_tests/charts/data/tree_table_guest_tests.py (on master it reports lines 704 and 841).
  3. Optionally run pytest tests/integration_tests/charts/data/tree_table_guest_tests.py against an integration test database and confirm the guest RLS tests still pass.

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

This is the same full-tree-only mypy mechanism (follow_imports = "skip" for superset_core.* hides superset_core types from scoped runs) as #46634, which handles the other errors in the same scheduled run. Culprit: #46490 (e81334c, feat(ag-grid-table): add a Tree query mode).

🤖 Generated with Claude Code

The full-tree mypy run flags tree_table_guest_tests.py:704 and :841:
GuestTokenRlsRule.dataset is typed Optional[str], but the tests passed
self.table.id (int). Scoped mypy runs resolve SqlaTable.id as Any
because superset_core is follow_imports=skip, so the per-PR check did
not catch it. Runtime compares str(rule["dataset"]) to str(dataset.id),
so behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sadpandajoe sadpandajoe added the ai:fix-master generated by AI to fix master branch label Nov 28, 2026
@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 4c24acf08d00

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.23%. Comparing base (9969fe9) to head (4c24acf).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #46668   +/-   ##
=======================================
  Coverage   86.23%   86.23%           
=======================================
  Files        3146     3146           
  Lines      220018   220018           
  Branches    52110    52110           
=======================================
  Hits       189725   189725           
  Misses      26823    26823           
  Partials     3470     3470           
Flag Coverage Δ
hive 33.63% <ø> (ø)
mysql 51.83% <ø> (-0.01%) ⬇️
postgres 51.85% <ø> (-0.01%) ⬇️
presto 35.32% <ø> (ø)
python 88.81% <ø> (ø)
sqlite 51.55% <ø> (ø)
unit 84.37% <ø> (ø)

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.

@hainenber
hainenber merged commit 0c347d9 into master Nov 28, 2026
81 checks passed
@hainenber
hainenber deleted the ultraset-tree-table-guest-tests-dataset-typeddict-int branch November 28, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:fix-master generated by AI to fix master branch size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants