Repository navigation
fix(auth): a corrupt cookie store is not a network problem (#796) - #1096
Merged
Merged
Conversation
browser_cookie3 raises sqlite3.DatabaseError for a cookie file that is not a database. It fell through to VERIFICATION_ERROR, so auth status said "check network connectivity" and the MCP twin answered 503 retryable. It is now its own outcome, COOKIE_STORE_UNREADABLE: the CLI says to close Chrome and re-login, and MCP returns 409, not retryable. It is not routed into the Playwright fallback, which would launch Chrome on the corrupt file during a read-only probe. Refs #796
|
Caution Review failedThe pull request is closed. Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… the login path (#796)
…atabaseError test On Linux/macOS browser_cookie3 asks the keyring for the key before opening the DB; CI has no keyring, so it falls back before reaching the corrupt file. The portable test injects the same sqlite3.DatabaseError where browser_cookie3 raises it.
# Conflicts: # CHANGELOG.md # docs/MCP.md # website/docs/MCP.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #796. A corrupt Chrome cookie database was reported as a network problem:
gflow auth statussaid "Check network connectivity and retry", and the MCPgflow_auth_statustool returnedverification_error(HTTP 503,retryable: true), which tells an agent to retry. This is the "adjacent finding" recorded on #796 when #797 landed: same wrong advice, different trigger.Root cause
browser_cookie3.chrome()raisessqlite3.DatabaseError("file is not a database")for a cookie file that is not a valid SQLite database. Its connection check only catchesOperationalError._get_chrome_cookies3(src/gflow_cli/auth/cookies.py) only turns decryption errors intoPermissionErrorfor the Playwright fallback, so theDatabaseErrorreached the catch-allexcept Exceptioninverify_flow_profile(src/gflow_cli/auth/verification.py) and becameVERIFICATION_ERROR. I checked this by running the realbrowser_cookie3on a garbage file, which raisedsqlite3.DatabaseError.Fix
FlowSessionOutcome.COOKIE_STORE_UNREADABLE.verify_flow_profilecatchessqlite3.DatabaseError(which also coversOperationalError) before the catch-all and returns this outcome.PermissionErrordoes. That would launch Chrome on a corrupt file during a read-only status probe, where Chrome may discard (raze) the database. On a profile with no marker it would also stop at the marker gate and give the wrong advice.gflow auth statussays: "This profile's cookie store is corrupt or unreadable. Close any Chrome window using this profile, then re-run gflow auth login --profile ."cookie_store_unreadable, HTTP 409,retryable: false. This matches the existingprofile_marker_missingenvelope (a local-state fault, neither 503 nor 401).retryable: falseis measured, not guessed: two back-to-back live runs gave the same outcome 2/2, because a retry reads the same broken file again.UNVERIFIED_MESSAGE/UNVERIFIED_HINTget the new outcome, so a login that verifies into it gets a clean message and not aKeyError.gflow_auth_statusentry indocs/MCP.md, plus the regenerated website mirror. CHANGELOG[Unreleased] ### Fixed.Evidence
TDD: three new tests failed for the right reason before the fix. The log showed
auth_flow_session_probe_error error=DatabaseError, and the CLI output contained "check network connectivity".tests/auth/test_verification.py::...::test_corrupt_cookie_store_is_not_reported_as_a_network_fault: a real corrupt file intmp_pathand the realbrowser_cookie3. It asserts the new outcome and that Playwright is never launched.tests/cli/test_auth_status.py::test_corrupt_cookie_store_is_not_blamed_on_the_network: end to end through the real probe.verify_flow_profileandbrowser_cookie3are not mocked.tests/mcp/test_auth_status_tool.py::test_an_unreadable_cookie_store_is_not_retryable_and_not_a_network_faultLive, $0, no browser launched. A real profile's marker files,
Local Stateand cookie DB were copied into a temporaryGFLOW_CLI_HOME. The copiedCookieswas then overwritten with random bytes. The original profile was not modified, and the copy has since been deleted.develop
624992d9:this branch:
E2E scope: this does not touch a Flow surface. The fault is a local file, and the path fails before any network call or browser launch. The live run above goes through the real CLI and MCP entry points.
Verification status
--check, council memory: all exit 0ruff checkclean,ruff format --checkcleanuv run pyright src: 0 errors, 0 warningstests/auth tests/cli tests/mcp -n 8 -m "not live and not e2e and not smoke": 1161 passedWhat remains on #796 (not in this PR)
Not touched here: the marker rollback after a failed verification (
real_chrome.py), which permanently demotes a chrome profile, and theGOOGLE_SESSION_ONLYre-login loop. The macOS Keychain leg is also still unverified (no Mac here). HenceRefs, notCloses.Refs #796