You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
auth.json corruption causes startup crash (sub-cause of #27530) #29628
opencode crashes on startup when auth.json is in a corrupted state (whitespace-only, truncated, or otherwise unparseable JSON). The crash is fatal -- the user cannot launch opencode at all until they manually delete or restore the file.
This is a sub-cause of umbrella issue #27530, which tracks multiple distinct startup-failure modes (provider-API 5xx, #-in-instructions parser crash, SSL/config failures). This issue narrows the scope to only the corrupted-auth.json case so it can be addressed independently.
Reproduction
Open ~/.local/share/opencode/auth.json (Linux/Mac) or %LOCALAPPDATA%\opencode\auth.json (Windows)
Replace the contents with whitespace, an empty string, or invalid JSON like { (simulating an interrupted write or disk-full event)
Launch opencode
Expected: opencode treats the corrupted file as if no auth exists, prompts the user to log in fresh, continues startup.
Actual: opencode throws an unhandled JSON parse exception during auth initialization, exits with a stack trace.
Why this happens
Interrupted writes to auth.json (Ctrl+C during save, sudden shutdown, disk-full, antivirus quarantine) leave the file in a partially-written state. The current auth loader calls JSON.parse() on the raw contents without a try/catch + recovery path, so any malformed content crashes the whole process.
Proposed fix
Treat corrupted auth.json as logically equivalent to a missing/empty auth.json -- i.e. proceed with no cached credentials and let the user re-authenticate. PR #29562 implements this: wraps the load in a try/catch that, on parse failure, logs a warning and returns an empty auth object.
Activity
github-actions commentedon Jul 27, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.