Repository navigation
Conversation
Code Review Agent Run #5221ffActionable 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 |
|
The flagged issue is correct. The superset/utils/machine_auth.py |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #43253 +/- ##
=======================================
Coverage 79.26% 79.26%
=======================================
Files 2888 2888
Lines 166464 166472 +8
Branches 38532 38532
=======================================
+ Hits 131950 131958 +8
Misses 32026 32026
Partials 2488 2488
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:
|
|
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR). 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 |
Code Review Agent Run #b608c4Actionable 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 |
|
@fitzee I think you were looking into alerts/reports so pinging you here. |
aminghadersohi
left a comment
There was a problem hiding this comment.
Verdict: sound, well-targeted fix. It wraps the login goto in a timeout guard so a slow-loading login page can no longer abort report authentication, and it does so by mirroring the exact pattern already used for the screenshot navigation. I reviewed the pinned head 5bcb565; CI is green (60 success / 9 skipped / 3 neutral, no failures). Not blocking on anything below — a couple of small notes and one test suggestion.
The fall-through on timeout is safe (not a finding — worth stating explicitly). The concern with swallow-and-continue would be delivering an unauthenticated / login-page screenshot. That can't happen here:
- Cookies are installed via
browser_context.add_cookies(...)with an explicitdomain=url.netloc(machine_auth.py:88-100). That does not depend on thegotohaving committed a navigation, so even a worst-case timeout leavingabout:blankstill installs the auth cookies on the context. - This
/login/page is never the screenshot target. The report image is captured downstream by a separatepage.goto(url, ...)to the real chart/dashboard URL inwebdriver.py:560, afterself.auth()has populated the context (webdriver.py:544-545).
So the change is strictly more robust than before: previously the bare page.goto("/login/") used Playwright's default wait_until="load" and would raise and abort auth on a slow page. Nice fix.
Addresses the codeant finding. The prior review flagged that introducing wait_until (e.g. networkidle) without catching PlaywrightTimeout would break auth on timeout. The try/except PlaywrightTimeout + fall-through here is exactly that fix. Confirmed for the next reader.
Notes (all non-blocking):
PlaywrightTimeout = Exceptionfallback — this matcheswebdriver.py:69-75byte-for-byte, so it's consistent with the established convention. It's also effectively unreachable at runtime: this handler only runs when a real PlaywrightBrowserContextwas passed in, which can't happen if playwright failed to import. Fine as-is; the narrower concern doesn't apply given the sibling precedent.- Config key —
SCREENSHOT_PLAYWRIGHT_WAIT_EVENTships with a default (config.py:1324="domcontentloaded"), so noKeyErrorrisk. Optional: read it into a local once instead of subscriptingapp.config[...]twice (thegotoand the log line). Cosmetic. - Minor behavior change — the login
gotopreviously waited for"load"and now waits for the configured event (defaultdomcontentloaded, which fires earlier). Benign, since login-page render doesn't affect cookie installation, and it aligns the twogotocalls. Worth a mention in the description. logger.exceptionlogs at ERROR with a traceback for a condition the code intentionally continues past;warningarguably fits better. That said,webdriver.py:570does the identicallogger.exceptionfor the same case, so keeping it consistent is defensible.
Tests. A module already exists (tests/integration_tests/utils/machine_auth_tests.py) and already mocks mock_page.goto. The new fall-through branch is trivially testable — mock_page.goto.side_effect = PlaywrightTimeout(...) and assert add_cookies is still called once — in ~5 lines. The PR adds none; existing tests still pass because the branch isn't exercised. Not blocking for a change this small, but a single test guarding "timeout still installs cookies" would lock in the exact property that makes this safe.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@aminghadersohi Added the a single test guarding "timeout still installs cookies" |
There was a problem hiding this comment.
Code Review Agent Run #7e2347
Actionable Suggestions - 1
-
tests/integration_tests/utils/machine_auth_tests.py - 1
- Missing clear_cookies assertion · Line 67-67
Review Details
-
Files reviewed - 1 · Commit Range:
5bcb565..48dab98- 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 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
Code Review Agent Run #b0134bActionable 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 |
|
@aminghadersohi ping! Could you review this? |
aminghadersohi
left a comment
There was a problem hiding this comment.
Round 2 — narrow scope. Since round 1 (my COMMENT at 5bcb565) the production file superset/utils/machine_auth.py is byte-identical (sha256 49d7c9da… at 5bcb565, bb15e94, and the current head 1e4a1bc), so round-1's verdicts stand and are not repeated here. 1e4a1bc is a pure master→patch-4 merge (parents bb15e94 + ac3c158); the authored diff across it is empty, so it introduces no semantic conflict in either authored file. That leaves exactly one previously-unreviewed change: the new test in machine_auth_tests.py. This review covers only that.
The new timeout test is genuinely coupled, not vacuous. test_authenticate_browser_context_sets_cookies_after_navigation_timeout injects mock_page.goto.side_effect = PlaywrightTimeout(...). Reverting only the production try/except PlaywrightTimeout (leaving a bare page.goto) makes the exception propagate out of authenticate_browser_context, so the result = provider.authenticate_browser_context(...) line raises before any assertion and the test goes RED. It therefore locks the exact behavior the PR adds. (Verified analytically by revert-reasoning; the integration harness is not runnable in my environment — /health is down — so I did not execute it. An environmental inability to run is not a PR defect.) The assertions are substantive, not identity checks: beyond "did not raise," it asserts add_cookies fired with the patched session=abc123 value (the real cookie-installation data path) and that clear_cookies fired. Importing PlaywrightTimeout from the module under test (not from playwright directly) is the right call — the raised type equals the caught type whether or not playwright is installed.
Security check (this file propagates session cookies into a screenshot browser context): no weaker guarantee, no leak. The test asserts that a navigation timeout still installs auth cookies, which reads like "a failure path grants auth" — but the auth is not derived from the navigation. get_auth_cookies(user) performs a server-side login_user(user) and harvests that user's own session cookie; add_cookies then installs it with an explicit domain=url.netloc, independent of whether page.goto("/login/") committed. The timeout affects only page render, not cookie derivation, so the timeout path produces the same auth state as the success path — for the same user, with no privilege change. clear_cookies() runs unconditionally before add_cookies(), so no cross-context residue is introduced on either path. The behavior the test pins is the strictly stronger one: a slow/failed login-page render must not abort authentication (the pre-PR behavior would have left an unauthenticated context and risked a login-page screenshot — the worse outcome, and the same class the sibling report-screenshot PRs hardened). This is intended and safe.
Prior bot finding addressed: bito's inline note (test-file thread, now resolved) flagged the missing clear_cookies assertion; the "Verify cookies" commit added exactly that. Confirmed present at head.
No blocking findings and nothing new to change. Non-blocking nit (optional, not tracked): neither this test nor the existing happy-path test asserts the cookie's domain field, which is the property that makes the fall-through safe — an explicit domain == url.netloc assertion would document that invariant, but its absence is a pre-existing convention, not a regression from this delta.
|
Nice catch, and the fix matches what the rest of the screenshot flow already does with |
|
Thanks for tracking this down, the timeout handling and the matching test look solid. Only blocker is |
|
Heya @kakoni, #44109 pulled the |
SUMMARY
MachineAuthProvider.authenticate_browser_context()callspage.goto(headless_url("/login/"))without
wait_until, so Playwright falls back to itsloaddefault. In deployments where/login/reachesdomcontentloadedbut never firesload, machine auth times out and thereport never gets to the screenshot step, even though the rest of the Playwright flow already
honors
SCREENSHOT_PLAYWRIGHT_WAIT_EVENT.This passes that config through to the auth navigation, making it consistent with the rest of
the screenshot flow. The default (
domcontentloaded) resolves the timeout while stayingconfigurable.
TESTING INSTRUCTIONS
Against a deployment where
/login/never completesload:page.goto(url, wait_until="load", timeout=60000)times outpage.goto(url, wait_until="domcontentloaded", timeout=60000)succeedsBefore the change, triggering a report snapshot fails during machine auth with
Page.goto: Timeout 60000ms exceeded ... waiting until "load". After, navigation completes andthe report proceeds. Also verified that setting the config to another supported Playwright event
is respected by the auth navigation.