Repository navigation
Conversation
`_copy_auth_files` decoded .credentials.json with strict UTF-8 and no error handling, so a single invalid byte — e.g. a truncated write from an interrupted login — raised UnicodeDecodeError and aborted the resume before the CLI was even spawned, even when the caller authenticates via ANTHROPIC_API_KEY and never needs the file. Treat an undecodable credentials file like a missing one: skip it and log a warning, matching the best-effort policy of the neighbouring seed-file helpers. Fixes anthropics#1521
This was referenced Nov 21, 2026
This branch has not been deployed
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
Fixes #1521.
_copy_auth_filesdecoded.credentials.jsonwith strict UTF-8 and no error handling, unconditionally and before the env-API-key branch. A single invalid byte in the file — e.g. a truncated write from an interrupted login — raisedUnicodeDecodeErrorand aborted the resume before the CLI was even spawned, even when the caller authenticates viaANTHROPIC_API_KEYand never reads that file.The change treats an undecodable credentials file like a missing one: skip it and log a warning, matching the best-effort policy of the neighbouring seed-file helpers (
_read_if_present,_strip_settings_for_resume).creds_jsonas before).Test plan
TestHappyPath::test_corrupt_credentials_file_does_not_abort_resume: seeding an invalid-UTF-8.credentials.jsonno longer aborts materialization, no credentials file is written, and the transcript is still materialized.mainwithUnicodeDecodeErroratsession_resume.py:345(the exact line from the issue) and passes with the fix.pytest tests/: 1757 passed, 6 skipped.ruff check,ruff format --check,mypy src/ scripts/all clean.