Skip to content

fix(reports): remove machine-auth priming navigation that can clobber the session cookie - #44109

Merged
sadpandajoe merged 3 commits into
apache:masterfrom
onionhammer:fix/machine-auth-priming-page-race
Sep 14, 2026
Merged

sadpandajoe merged 3 commits into
apache:masterfrom
onionhammer:fix/machine-auth-priming-page-race

Conversation

@onionhammer

@onionhammer onionhammer commented Sep 9, 2026 •

Copy link
Copy Markdown

authenticate_browser_context() opened a page on /login/ to "prime" the cookie jar and never closed it. That page keeps issuing requests after page.goto() resolves, and any response carrying an anonymous "Set-Cookie: session=..." that lands after add_cookies() overwrites the injected cookie in the shared browser context. The whole context then silently reverts to anonymous: every request 302s to /login/, the screenshot renders the login screen, .standalone never appears, and the report fails with a misleading

Locator.wait_for: Timeout ... waiting for locator(".standalone")

Being a race, it only loses when /login/ is slow to settle -- in practice the first request after a long idle period, which is exactly when scheduled reports tend to run.

The navigation is a Selenium carryover: driver.add_cookie() requires already being on the domain, but BrowserContext.add_cookies() takes the domain directly. It is also demonstrably redundant here, since clear_cookies() already discards everything the login page set before the real cookies are injected.

Nothing downstream depends on it: WebDriverPlaywright.get_screenshot() creates its own page after calling auth(), and the POSTs the screenshot page makes (charts data, log, cache_dashboard_screenshot) are all in WTF_CSRF_EXEMPT_LIST.

Fixes #44005

SUMMARY

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

… the session cookie

authenticate_browser_context() opened a page on /login/ to "prime" the cookie
jar and never closed it. That page keeps issuing requests after page.goto()
resolves, and any response carrying an anonymous "Set-Cookie: session=..." that
lands after add_cookies() overwrites the injected cookie in the shared browser
context. The whole context then silently reverts to anonymous: every request
302s to /login/, the screenshot renders the login screen, .standalone never
appears, and the report fails with a misleading

    Locator.wait_for: Timeout ... waiting for locator(".standalone")

Being a race, it only loses when /login/ is slow to settle -- in practice the
first request after a long idle period, which is exactly when scheduled reports
tend to run.

The navigation is a Selenium carryover: driver.add_cookie() requires already
being on the domain, but BrowserContext.add_cookies() takes the domain directly.
It is also demonstrably redundant here, since clear_cookies() already discards
everything the login page set before the real cookies are injected.

Nothing downstream depends on it: WebDriverPlaywright.get_screenshot() creates
its own page after calling auth(), and the POSTs the screenshot page makes
(charts data, log, cache_dashboard_screenshot) are all in WTF_CSRF_EXEMPT_LIST.

Fixes apache#44005

Signed-off-by: Erik O'Leary <[email protected]>
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e3bbd4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: f71c4e9..f71c4e9
    • superset/utils/machine_auth.py
    • tests/integration_tests/utils/machine_auth_tests.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 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

@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.14%. Comparing base (e5c2a3e) to head (990033d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44109      +/-   ##
==========================================
- Coverage   80.14%   80.14%   -0.01%     
==========================================
  Files        2924     2924              
  Lines      172370   172313      -57     
  Branches    40018    39987      -31     
==========================================
- Hits       138147   138092      -55     
+ Misses      31637    31635       -2     
  Partials     2586     2586              
Flag Coverage Δ
hive 37.34% <ø> (+<0.01%) ⬆️
mysql 56.90% <ø> (-0.01%) ⬇️
postgres 56.93% <ø> (-0.01%) ⬇️
presto 39.23% <ø> (+<0.01%) ⬆️
python 84.51% <ø> (-0.01%) ⬇️
sqlite 56.63% <ø> (-0.01%) ⬇️
unit 75.80% <ø> (+<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.

@sadpandajoe
sadpandajoe merged commit f35de69 into apache:master Sep 14, 2026
75 checks passed
@onionhammer
onionhammer deleted the fix/machine-auth-priming-page-race branch September 14, 2026 17:33
villebro pushed a commit that referenced this pull request Sep 16, 2026
… the session cookie (#44109)

Signed-off-by: Erik O'Leary <[email protected]>
(cherry picked from commit f35de69)
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.

Machine auth's /login/ priming page can clobber the injected session cookie, sending screenshots to the login screen

3 participants