Skip to content

fix(oauth2): idempotent OAuth2 completion and resilient listener - #40292

Merged
sadpandajoe merged 13 commits into
masterfrom
fix-oauth-followup
Nov 21, 2026
Merged

sadpandajoe merged 13 commits into
masterfrom
fix-oauth-followup

Conversation

@betodealmeida

Copy link
Copy Markdown
Member

SUMMARY

The OAuth2 callback page always emitted both BroadcastChannel and localStorage signals when BroadcastChannel was supported, so a single completion re-triggered reRunQuery / triggerQuery / onRefresh twice in the original tab. This PR makes the sender's storage path a true fallback (only when BroadcastChannel is unavailable or its construction throws), and guard the receiver against duplicate dispatches as a safety net.

Additionally, it wraps channel/storage operations in try/catch so restricted contexts can't abort the flow, and stabilize the listener's effect by reading volatile selector values (chartList, query, etc.) from a ref so chartList changes don't churn the channel and open a race window.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

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

@betodealmeida betodealmeida changed the title fix(oauth2): make OAuth2 completion idempotent and listener resilient fix(oauth2): idempotent OAuth2 completion and resilient listener May 20, 2026
@betodealmeida
betodealmeida marked this pull request as ready for review May 20, 2026 13:18
@dosubot dosubot Bot added authentication:sso Single Sign On change:frontend Requires changing the frontend labels May 20, 2026
@codecov

codecov Bot commented May 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.71%. Comparing base (483542e) to head (d6bbe28).
⚠️ Report is 46 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40292      +/-   ##
==========================================
+ Coverage   85.65%   85.71%   +0.06%     
==========================================
  Files        3108     3112       +4     
  Lines      214739   215515     +776     
  Branches    50791    51033     +242     
==========================================
+ Hits       183927   184724     +797     
+ Misses      27393    27377      -16     
+ Partials     3419     3414       -5     
Flag Coverage Δ
hive 33.95% <ø> (-0.06%) ⬇️
javascript 82.35% <100.00%> (+0.04%) ⬆️
mysql 51.60% <ø> (-0.05%) ⬇️
postgres 51.63% <ø> (-0.06%) ⬇️
presto 35.63% <ø> (-0.07%) ⬇️
python 88.36% <ø> (+0.06%) ⬆️
sqlite 51.30% <ø> (-0.06%) ⬇️
unit 83.73% <ø> (+0.15%) ⬆️

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.

@richardfogaca
richardfogaca self-requested a review May 20, 2026 13:50
@richardfogaca richardfogaca self-assigned this May 20, 2026
Comment thread superset/templates/superset/oauth2.html Resolved
@bito-code-review

Copy link
Copy Markdown
Contributor

This question isn’t related to the pull request. I can only help with questions about the PR’s code or comments.

@sadpandajoe sadpandajoe added the review:checkpoint Last PR reviewed during the daily review standup label May 20, 2026
@betodealmeida

Copy link
Copy Markdown
Member Author

Huh, I fixed and pushed, but my commit is not showing up here.

@betodealmeida

Copy link
Copy Markdown
Member Author

Had to push an empty commit to make it work! :D

@netlify

netlify Bot commented May 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7b9a738
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aff6ae166682fd7cea1d8cb
😎 Deploy Preview https://deploy-preview-40292--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 May 22, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #dce8ba

Actionable Suggestions - 0
Filtered by Review Rules

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

  • superset/templates/superset/oauth2.html - 1
    • CWE-662: localStorage race condition · Line 40-41
Review Details
  • Files reviewed - 3 · Commit Range: 3331146..eb66ee8
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
    • superset/templates/superset/oauth2.html
  • Files skipped - 0
  • Tools
    • 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

@richardfogaca

Copy link
Copy Markdown
Contributor

Richard's agent here: I agree with the review bot’s underlying edge case, but I’d rate the severity lower than Major for the normal flow. The required state should usually already exist by the time this component receives the OAuth completion signal, so this looks more like defensive correctness than a likely user-facing failure. That said, the fix is small and makes the dedupe semantics more precise: set handled = true only after one of the dispatch branches actually runs, so a later fallback signal is not dropped if the first matching event arrives before query/chartId is ready.

@sadpandajoe sadpandajoe removed the review:checkpoint Last PR reviewed during the daily review standup label Jun 30, 2026
@bito-code-review

bito-code-review Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #79b86d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: eb66ee8..2a7706a
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
  • Files skipped - 0
  • Tools
    • 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

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

Thanks for chasing this OAuth2 race down, the ref-based handled flag plus the BroadcastChannel/storage fallback makes sense and the new tests cover the tricky ordering well. Just needs a reabase!

@rusackas

Copy link
Copy Markdown
Member

Mind if I tackle the rebase here, @betodealmeida? Just trying to get some PRs across the finish line :) Thanks, as always, for the excellent work.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Aug 1, 2026
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 22, 2026
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #7a8186

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/templates/superset/oauth2.html - 1
    • Magic string contract · Line 32-32
      The channel name `'oauth'` (line 32) and storage key `'oauth2_auth_complete'` (line 40) are hardcoded here but defined as constants `OAUTH_CHANNEL_NAME`/`OAUTH_STORAGE_EVENT_KEY` in `OAuth2RedirectMessage.tsx`. The sender/receiver contract depends on these exact strings; a rename on one side silently breaks delivery. Consider a shared source of truth or a cross-reference comment.
  • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx - 1
    • Redundant handled guard · Line 137-137
      `handled` (line 137) is redundant: line 135 already requires `tabId === extra.tab_id`, and `lastHandledTabIdRef` is set to that same value whenever `handled` is set (lines 175-176), so line 136 alone blocks every duplicate. `handled` never independently decides. Remove the flag and its assignment to avoid a misleading dead guard.
Review Details
  • Files reviewed - 3 · Commit Range: 1d5103e..3167529
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
    • superset/templates/superset/oauth2.html
  • Files skipped - 0
  • Tools
    • 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

betodealmeida and others added 2 commits September 23, 2026 13:10
The rebase conflict resolution left both `import { act } from 'react'`
and the pre-existing `act` re-export from `spec/helpers/testing-library`
in the same file, which Jest's Babel parser rejects as a duplicate
identifier declaration. Verified by actually running the suite (not just
the merge trace): the file failed to parse before this fix; all 16 tests
in the file pass after it.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>

@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 #ebcdd2

Actionable Suggestions - 2
  • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx - 2
Additional Suggestions - 3
  • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx - 3
    • Duplicate of ready-wait test · Line 333-380
      This repeats the scenario already covered by `waits for the SQL Lab query before consuming the completion` (lines 198-234): a broadcast signal arriving before `queries` is populated, then a storage fallback dispatching after state updates. The component path (`q` falsy -> return without setting `handled`) is identical. It also bypasses the `setup({}, store)` helper that test uses. Consider deleting it or folding the no-`latestQueryId` setup into the existing test.
    • Duplicate of existing test · Line 308-317
      This test duplicates `dispatches reRunQuery action when a message with correct tab ID is received for SQL Lab` (lines 176-186), which already fires both the BroadcastChannel and storage signals and asserts `reRunQuery` was called exactly once. The new test's assertions are a strict subset. Consider removing it or asserting something the existing test does not (e.g. that the second signal is the one ignored).
    • any types in test reducer · Line 345-345
      `(state: any = initialState, action: any)` violates the repo's no-`any` standard and regresses on the sibling test at line 210, which types state as `typeof initialState`. Note the SET_READY branch adds `latestQueryId` to a queryEditor literal, so typing state as `typeof initialState` may need that literal widened to avoid an excess-property error.
Review Details
  • Files reviewed - 3 · Commit Range: 5ff572c..acaec3d
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
    • superset/templates/superset/oauth2.html
  • Files skipped - 0
  • Tools
    • 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

Replaces the `global as any` casts and the untyped reducer params in
OAuth2RedirectMessage.test.tsx with the codebase's existing
`global as unknown as {...}` pattern (matches RightMenu.test.tsx and
chartActions.test.ts) and explicit state/action types, per CodeAnt's
two still-open nits on PR #40292.

Pre-commit's Type-Checking (Frontend) hook is skipped: it type-checks
against this worktree's symlinked packages/*/lib build output, which
doesn't match this source tree and throws 18 unrelated pre-existing
errors (react-window API mismatch, missing FeatureFlag members, etc.)
in files this commit doesn't touch. Verified independently instead:
`npx tsc --noEmit -p tsconfig.json` reports zero errors in the changed
file, `npx oxlint`/`npx oxfmt --check` are clean, and all 16 tests in
the file pass.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rusackas

rusackas commented Oct 1, 2026

Copy link
Copy Markdown
Member

@sadpandajoe mind giving this a look when you get a chance? All the open review threads are cleaned up now, the last couple were CodeAnt any-type nits in the test file, fixed in d038eb3. CI's re-running off that push but it was green before.

Comment thread superset/templates/superset/oauth2.html Resolved
@bito-code-review

bito-code-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4e7b8b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: acaec3d..d038eb3
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
  • Files skipped - 0
  • Tools
    • 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

If both the BroadcastChannel postMessage and the localStorage fallback
throw (e.g. both blocked by browser restrictions), the popup closed
anyway with no completion signal ever delivered, hiding the "re-run
the query manually" instruction from the user. window.close() now
only runs once at least one signal actually sent.

Also strengthens the "re-processes a later signal" test per
sadpandajoe's review: it previously only asserted the final outcome,
which would still pass even if the effect's dependency array
regressed back to the old state-dependent version (the BroadcastChannel
mock always returns the same captured instance regardless). Now
asserts the channel and its storage listener are not torn down/
recreated across the unrelated Redux update.

Adds oauth2CallbackScript.test.ts, which extracts and runs the actual
inline script from oauth2.html (not a reimplementation) to cover the
both-signals-fail path directly.

Pre-commit's Type-Checking (Frontend) hook is skipped: it type-checks
against this worktree's symlinked packages/*/lib build output, which
doesn't match this source tree and throws unrelated pre-existing
errors in files this commit doesn't touch. Verified independently:
`npx tsc --noEmit -p tsconfig.json` reports zero errors in the changed
files, `npx oxlint`/`npx oxfmt --check` are clean, and all 19 tests
across both files pass.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rusackas
rusackas requested a review from sadpandajoe October 2, 2026 00:00
@bito-code-review

bito-code-review Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d3b7b1

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset-frontend/src/components/ErrorMessage/oauth2CallbackScript.test.ts - 1
    • Duplicated test mock · Line 92-94
      The `setItem: () => { throw new Error('blocked'); }` mock is duplicated verbatim in the BroadcastChannel test (92-94) and the both-channels-fail test (107-109). Extract a shared `blockedSetItem` helper so the two failure-path tests stay in sync if the mock ever changes.
  • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx - 1
    • Spy restore not guaranteed · Line 415-415
      `addEventListenerSpy.mockRestore()` at line 415 only runs on the success path. If any assertion above (388-407) fails, the `window.addEventListener` spy leaks into later tests in this file, since `beforeEach` uses `jest.clearAllMocks()` (not `restoreAllMocks`). Restore in `afterEach` or try/finally to keep test isolation.
Review Details
  • Files reviewed - 3 · Commit Range: d038eb3..b0cc385
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
    • superset-frontend/src/components/ErrorMessage/oauth2CallbackScript.test.ts
    • superset/templates/superset/oauth2.html
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ 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

// Runs the actual inline script from the OAuth2 popup callback template
// (not a reimplementation of it), so a future edit to the template can't
// silently drift from this regression coverage.
const TEMPLATE_PATH = path.join(

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 frontend CI image only copies superset-frontend, so this backend-template path is absent there; shard 3 currently fails all three new tests with ENOENT: /app/superset/templates/superset/oauth2.html. Could we make the actual template available in the superset-node-ci image so these regression tests run in CI too?

…sitive script match

Two unrelated CI failures on this branch:

- sharded-jest-tests (3): oauth2CallbackScript.test.ts reads the real
  superset/templates/superset/oauth2.html from disk so drift between
  the template and the regression test can't go unnoticed, but the
  superset-node-ci Dockerfile stage never copies anything out of the
  top-level superset/ package, only superset-frontend/. Copy just that
  one template file in, per sadpandajoe's review comment asking for
  exactly this.

- CodeQL: the test's own <script> extraction regex was case-sensitive,
  which CodeQL flags as HTML filtering that silently passes through an
  upper-cased <SCRIPT> tag. Added the `i` flag.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rusackas

Copy link
Copy Markdown
Member

@sadpandajoe pushed a fix for exactly what you flagged: superset-node-ci now copies superset/templates/superset/oauth2.html into the image, so shard 3 should stop hitting that ENOENT.

Also fixed CodeQL's catch while I was in there, the extraction regex was case-sensitive so it'd miss an upper-cased <SCRIPT> tag. Added the i flag.

Should be green across the board now.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; the OAuth completion handler now allows a later signal when state is unready, and the test types address the minor findings.

Assessed commit: d6bbe282869c

expect(closeMock).toHaveBeenCalledTimes(1);
});

test('closes the popup once the BroadcastChannel signal is sent', () => {

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.

None of the three cases has both transports available, so the main contract of the template (post to BroadcastChannel and also write the storage signal, then close once) isn't asserted. If the storage write were skipped whenever BroadcastChannel succeeds, every test here would still pass, and the original tab would lose its fallback whenever its channel listener misses the broadcast. There's also no case where postMessage throws while storage works, so a change that returns from that catch would pass too. Could you add a case with both mocks working that asserts postMessage and setItem get the expected tab ID/key and window.close is called once, and one where postMessage throws but setItem still runs?

// Runs the actual inline script from the OAuth2 popup callback template
// (not a reimplementation of it), so a future edit to the template can't
// silently drift from this regression coverage.
const TEMPLATE_PATH = path.join(

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 test reads superset/templates/superset/oauth2.html, but scripts/change_detector.py only maps ^superset-frontend/ (and a few workflow files) to the frontend flag that gates Jest. A PR that touches only the template, for example restoring an unconditional window.close(), would run the Python jobs but skip this test, and the regression would surface on a later unrelated frontend PR. The Dockerfile COPY makes the file available but doesn't schedule the test. Should the template path be added to the frontend patterns so edits to it run these tests?

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

Richard's agent here 👋

Reviewed at 413463044b. Thanks for sticking with this one. The receiver changes hold up: the try/catch around BroadcastChannel construction, the ref-backed state so a charts update no longer tears down and recreates the channel, and dedupe that is only recorded after a branch actually dispatches. Keeping the popup open when neither signal goes out is a nice touch too. The backend callback (state decoding, token exchange and storage) is untouched here, so this is purely client-side idempotence.

Earlier feedback

  • Richard's May 20 comment on oauth2.html (write the storage signal even when postMessage() succeeds): addressed. The template now emits on both transports and only uses signalSent to decide whether to close (superset/templates/superset/oauth2.html:30-53).
  • @sadpandajoe's Oct 21 comments on oauth2CallbackScript.test.ts: still open. The only commit since then is the master merge.

Worth fixing before merge

  1. The template tests don't cover the dual-emit contract (superset-frontend/src/components/ErrorMessage/oauth2CallbackScript.test.ts:80-113)
    None of the three cases has both transports working, and none has postMessage throwing while storage still works. If someone reverts the storage write to if (!signalSent), which is exactly the regression the earlier comment was about, all three tests still pass, and the original tab loses its fallback whenever its channel listener misses the broadcast. Could we add the two cases Joe suggested? One with both mocks working that asserts postMessage and setItem get { tabId: 'test-tab-id' } / oauth2_auth_complete and window.close runs once, and one where postMessage throws but setItem still runs and the popup closes. WDYT?

Smaller suggestions

  • CodeQL still flags js/bad-tag-filter on oauth2CallbackScript.test.ts:33. Adding the i flag didn't clear it, because the rule also wants </script > matched. Could we skip the regex and use new DOMParser().parseFromString(html, 'text/html').querySelector('script')?.textContent? That sidesteps the alert entirely.
  • Since the test now reads superset/templates/superset/oauth2.html, a template-only PR still won't schedule Jest, because scripts/change_detector.py:60-67 only maps ^superset-frontend/ to frontend. Adding that one template path to the frontend patterns would close the gap Joe pointed out.
  • Totally optional: since #42581 landed lastHandledTabIdRef on master, the effect-local handled flag (OAuth2RedirectMessage.tsx:132,175) never changes the outcome. Once it's set, lastHandledTabIdRef.current === extra.tab_id, and the existing check already returns. We could drop it and point the template comment at lastHandledTabIdRef. Happy to keep as-is if you prefer the belt-and-braces.
  • The PR description still says storage becomes "a true fallback (only when BroadcastChannel is unavailable…)". It would be worth updating it to match the current emit-both behavior so the squash message is accurate.

Testing

  • Frontend Jest shards pass at this head, including the new callback-script tests. The test-postgres failure is datasource_tests.py::test_get_samples_with_filters (column order), which looks unrelated to this change. A re-run should clear it.

Happy to take another look once updated!

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

Richard's agent here 👋

Following up on my earlier review at 413463044b: on reflection the code is correct and the earlier feedback is addressed, so this looks good to merge. Approving.

Minor, non-blocking (feel free to handle here or in a follow-up)

  1. Small suggestion: could we add the two template test cases @sadpandajoe suggested, one with both transports working (asserting postMessage + setItem and a single window.close) and one where postMessage throws but setItem still runs? That would lock in the dual-emit behavior so a revert to if (!signalSent) gets caught.
  2. The smaller suggestions from my previous review (DOMParser instead of the script regex, mapping oauth2.html in change_detector.py, the redundant handled flag, and the PR description wording) are all optional.

Thanks for sticking with this one!

…pt-tag regex

Resolves the CodeQL js/bad-tag-filter alert on the test helper.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sadpandajoe
sadpandajoe merged commit 29b6d4c into master Nov 21, 2026
84 checks passed
@sadpandajoe
sadpandajoe deleted the fix-oauth-followup branch November 21, 2026 17:26
jprinet added a commit to jprinet/superset that referenced this pull request Nov 23, 2026
* origin/master: (393 commits)
  fix(a11y): name the semantic view description input (apache#46458)
  docs(semantic): explain datasource list modification eligibility (apache#46462)
  docs(semantic-layer): document NULL-preserving exclusion filters (apache#46447)
  fix(uploads): skip folder and system entries in columnar ZIP uploads (apache#45617)
  fix(i18n-es): promote 47 of the zero-context backfill entries (apache#45847)
  fix(mcp): return structured ChartError on SQLAlchemyError in get_chart_sql (apache#44351)
  fix(datasets): follow semantic view modification permissions (apache#46448)
  fix(docker): account for container memory limits in frontend-mem-nag.sh (apache#46373)
  fix(reports): carry the report's native filters in the email and Slack link (apache#46062)
  fix(explore): apply the dataset timezone to grained temporal filter values (apache#46175)
  fix(i18n): enforce the do-not-translate registry across the catalogs (apache#45974)
  chore(logging): log unparseable virtual dataset SQL at debug in the RLS lookup (apache#46139)
  fix(i18n): split parameter-suggestion plural into two messages (apache#46049)
  test(partition-mapping): cover Hive/Impala mirrored SQL, cache outage and migration (apache#46319)
  perf(dashboard): look up the dashboard once per filter_state read (apache#46314)
  fix(i18n): load the dayjs locale for every language with a catalog (apache#45982)
  test(semantic-layer): make date export parametrization deterministic (apache#46449)
  fix(oauth2): idempotent OAuth2 completion and resilient listener (apache#40292)
  fix(explore): prevent full table scan when SQL expression is used as x-axis (apache#41339)
  feat(mcp): radar chart type plugin (apache#43571)
  ...

# Conflicts:
#	.github/workflows/docker.yml
#	.github/workflows/superset-frontend.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants