Repository navigation
fix(reports): remove machine-auth priming navigation that can clobber the session cookie - #44109
Conversation
… 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]>
Code Review Agent Run #e3bbd4Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
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:
|
… the session cookie (#44109) Signed-off-by: Erik O'Leary <[email protected]> (cherry picked from commit f35de69)
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
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