fix: --fresh fails to clean cookie_storage, auth_svc crashes on key mismatch#3355
Open
fix: --fresh fails to clean cookie_storage, auth_svc crashes on key mismatch#3355
Conversation
…ismatch - Add data/cookie_storage to DATA_FILE_GLOBS so --fresh removes it - Catch SystemExit in auth_svc when file_svc._read() fails to decrypt stale cookie_storage; regenerate session key instead of crashing - Add tests: DATA_FILE_GLOBS membership + stale cookie recovery Fixes crash when switching between --insecure and secure mode after PR #3264 introduced persistent session cookies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes --fresh cleanup and startup robustness for persistent sessions by ensuring data/cookie_storage is treated as managed state and by preventing auth_svc from crashing when the encryption key used to decrypt cookie_storage changes.
Changes:
- Add
data/cookie_storagetoDATA_FILE_GLOBSsoDataService.destroy()(used by--fresh) removes it. - Update
AuthService.apply()to recover fromcookie_storagedecryption failure by deleting the stale file and regenerating a session key instead of terminating the server. - Add tests validating glob membership and key-mismatch recovery behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/service/data_svc.py | Includes data/cookie_storage in the --fresh managed deletion globs. |
| app/service/auth_svc.py | Catches SystemExit from file_svc._read() on key mismatch and regenerates cookie_storage. |
| tests/services/test_fresh_cleanup.py | Adds regression tests for DATA_FILE_GLOBS membership and stale-cookie recovery. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
data/cookie_storagetoDATA_FILE_GLOBSso--freshproperly removes itauth_svcgracefully: catchSystemExitfromfile_svc._read(), regenerate session key instead of crashingProblem
After PR #3264 (persistent sessions),
data/cookie_storageis saved as an encrypted file. When the encryption key changes (e.g., switching between--insecureand secure mode),--freshfails to clean it because it's not in the managed file list. On next startup,file_svc._read()hitsInvalidTokenand callssys.exit(1), crashing the server even with--fresh.Reproduction
Changes
app/service/data_svc.pydata/cookie_storagetoDATA_FILE_GLOBSapp/service/auth_svc.pySystemExitfrom_read(), delete stale cookie, regenerate keytests/services/test_fresh_cleanup.pyTest plan
--freshnow removesdata/cookie_storageBaseWorld._app_configuration— no state leakage🤖 Generated with Claude Code