GeezerVison is showing github.com — Error: 4 of 5 requests failed: config.providers: Unexpected server error. · Issue #27530 · anomalyco/opencode
Error: 4 of 5 requests failed: config.providers: Unexpected server error. #27530DescriptionDescription
When starting the app via opencode executable:
Error: 4 of 5 requests failed: config.providers: Unexpected server error. Check server logs for details.; provider.list: Unexpected server error. Check server logs for details.; app.agents: Unexpected server error. Check server logs for details.; config.get: Unexpected server error. Check server logs for details.
at qG (/$bunfs/root/chunk-gt0me4ve.js:469:625)
at <anonymous> (/$bunfs/root/chunk-gt0me4ve.js:469:6032)
at processTicksAndRejections (native:7:39)
Plugins
No response
OpenCode version
(version: 1.14.49)
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response Reacted by Kubo Satnik, Musq6, Vincent Gillot, AnttiCandour, Lucas Pedro Bordignon, Zsolt Revay, Jan K, Adam Tajti, Thomas Roche, jgirault and 11 more ActivitySmurf81 commented on May 15, 2026 same here after i shutdown opencode with "Ctrl+C" when he was in "Building"
ERROR 2026-05-15T12:02:02 +2ms service=server error=ConfigInvalidError cause=ConfigInvalidError: ConfigInvalidError
at zj (/$bunfs/root/chunk-k835vey5.js:710:82)
at <anonymous> (/$bunfs/root/chunk-k835vey5.js:712:8940)
at Config.loadInstanceState (/$bunfs/root/chunk-k835vey5.js:714:5025)
at Config.loadInstanceState (definition) (/$bunfs/root/chunk-k835vey5.js:714:81)
at Config.state (/$bunfs/root/chunk-k835vey5.js:675:20296)
at Config.state (definition) (/$bunfs/root/chunk-k835vey5.js:714:4981)
at Config.get (/$bunfs/root/chunk-nxmfg3zm.js:37:6483)
at Config.get (definition) (/$bunfs/root/chunk-k835vey5.js:714:5052)
at InstanceBootstrap (/$bunfs/root/chunk-nxmfg3zm.js:37:6712)
at InstanceStore.boot (/$bunfs/root/chunk-ar3awd7v.js:2:1490)
at InstanceStore.load (/$bunfs/root/chunk-ar3awd7v.js:2:2651) failed
``̀
chrissound commented on May 15, 2026 A workaround solution... Because I keep being unable to start opencode for past weeks.. Is just run HOME=/tmp/opencodetmp123 opencode... Of course it'll not persist your sessions etc using this. Smurf81 commented on May 15, 2026
A workaround solution... Because I keep being unable to start opencode for past weeks.. Is just run HOME=/tmp/opencodetmp123 opencode... Of course it'll not persist your sessions etc using this.
same error for me
Try to uninstall & re-install but same thing .....
FIX : in opencode.jsonc i was using
"agents": {
"context": [
"./AGENTS.md"
]
}
this is not working anymore and crash opencode on version 1.15.0, need to change to
"instructions": ["AGENTS.md"]
Reacted by kylie ski, 项科深 Xiang Keshen and Narmer Osorio Qesire commented on May 15, 2026 Same issue comes out of me trying start the Opencode in VSCode after my accidentally closing the bash when Opencode building something directly. I've tried reinstall, upgrade but effortless. Zsolt-R commented on May 15, 2026 Same, accidentally closed the terminal while it was building now I am getting the same error. gaoxingyi1024 commented on May 18, 2026 1、uninstall opencode
2、remove these files below
3、install opencode
%USERPROFILE%.cache\opencode
%USERPROFILE%.local\share\opencode
%USERPROFILE%.config\opencode Reacted by Max Mazurov, forever8, Mauricio C., Carlos Costa, mortenbj-statnett, Lucas Criado, kiu and wxwxnzm SimplyJoshi commented on May 19, 2026 Root cause: auth.json corrupted with whitespace-only contents
I hit this on Windows 11 with opencode 1.15.5 and traced it to a specific failure mode that I think explains every "Ctrl+C while building" / "closed the terminal mid-build" report above. Posting the diagnosis in case it helps the maintainers and the next person who lands here.
What the server is actually crashing on
The TUI-facing error (4 of 5 requests failed: config.providers, provider.list, app.agents, config.get) is downstream noise. The real failure in the server log is a JSON parse error inside Auth.all():
ERROR ... service=server error=JSON Parse error: Unrecognized token ' '
cause=SyntaxError: JSON Parse error: Unrecognized token ' '
at FileSystem.readJson (chunk-y6vv15b7.js)
at Auth.all (chunk-y6vv15b7.js)
at Config.loadInstanceState (chunk-y6vv15b7.js)
at Config.state (chunk-y6vv15b7.js)
at Config.get (chunk-hqfz04v1.js)
Every config-dependent request goes through Config.get -> Config.loadInstanceState -> Auth.all -> readJson(auth.json). When that parse throws, every one of those requests fails with the same generic "Unexpected server error", which is why the user sees four failures instead of one. Logs live at ~/.local/share/opencode/log/*.log (or %USERPROFILE%\.local\share\opencode\log\ on Windows) — searching them for Auth.all surfaces the cause immediately.
What the files looked like
On my machine, both auth.json files existed and were non-empty, but contained only whitespace — no JSON, not a single {:
| Path |
Size |
Contents |
%LOCALAPPDATA%\opencode\auth.json |
327 bytes |
327 space characters |
%USERPROFILE%\.local\share\opencode\auth.json |
543 bytes |
543 space characters |
Both files had identical modification timestamps down to the second.
Why this happens
The byte counts strongly suggest a non-atomic write. The file is opened with O_TRUNC, the buffer is padded with spaces, and the actual JSON payload is supposed to overwrite that padding before the file is closed — but if the process is killed (Ctrl+C, terminal closed, OS shutdown) before the write completes, the file is left at its full size, filled with 0x20. The filesystem still sees a "valid" non-empty file, so nothing flags it as broken.
This matches every report above where the problem started after interrupting opencode while it was "Building". That's the window in which the auth file is being rewritten.
The parser then fails fatally instead of treating an unreadable auth file as "no credentials configured", which traps the user: they cannot open the TUI to run auth login, because the TUI refuses to bootstrap without a parseable auth file. Catch-22.
Recovery (no reinstall needed)
Overwrite both files with an empty JSON object, then re-authenticate. This worked instantly on my machine and preserves sessions, config, plugins, etc.
Windows (PowerShell):
Set-Content "$env:LOCALAPPDATA\opencode\auth.json" '{}'
Set-Content "$env:USERPROFILE\.local\share\opencode\auth.json" '{}'
opencode auth login
macOS / Linux:
echo '{}' > "$HOME/.local/share/opencode/auth.json"
# also check $XDG_DATA_HOME/opencode/auth.json if you've overridden it
opencode auth login
The "uninstall + nuke .cache, .config, .local/share" workaround posted earlier works because it deletes the corrupted file along with everything else. The targeted fix is just the two auth.json files — no need to lose your sessions, projects, or installed plugins.
Suggested fixes
- Atomic write for
auth.json — write to auth.json.tmp and rename() over auth.json. POSIX rename and Windows MoveFileEx with MOVEFILE_REPLACE_EXISTING are both atomic at the filesystem level: an interrupted process either leaves the old file intact or replaces it with the fully-written new one, never a half-written state. This eliminates the failure mode entirely.
- Lenient parse on read — if
auth.json is empty, whitespace-only, or otherwise malformed, log a warning and treat it as {} rather than crashing the bootstrap. The TUI should always start; an unparseable auth file is a "no providers configured" condition, not a fatal one. Users can then run opencode auth login to recover from inside the app.
- Surface the real cause — the user-facing
4 of 5 requests failed: config.providers... message doesn't mention auth.json or the underlying SyntaxError. Including the offending file path and the parse error in the bootstrap error would let users self-diagnose without grepping log files.
Environment
- opencode 1.15.5
- Windows 11 Pro (build 26200)
- Bun runtime (bundled)
Happy to test a patch or attach more log detail if it helps. Reacted by Joshua Sánchez, Knowingthesea_Qesire, dduart3, Victor Elci, Sean "Sharky" McMains, Pink Champagne, Mehdi and ysr.easy AlexMikhalev commented on May 21, 2026 Detailed investigation with root cause analysis
I hit this exact crash on v1.15.5 (Linux) and traced it to a provider API returning 5xx during startup, which causes opencode to crash rather than degrade gracefully.
Crash log (`/tmp/opencode-debug.log`)
```
Error: 2 of 5 requests failed: Unexpected server error. Check server logs for details.
Affected startup requests: config.providers, provider.list
at jO (/$bunfs/root/chunk-5pecsz7x.js:470:117)
```
Root cause
During startup opencode fires 5 parallel requests. Two failed:
- `config.providers` -- validates provider configurations by initialising each provider
- `provider.list` -- fetches available models via the plugin's `provider.models` hook
Both hit the provider API (in my case Kimi API at `https://api.kimi.com/coding/v1\`) which returned a 5xx server error.
Why it crashes instead of degrading
The `opencode-kimi-full` plugin (v1.4.0) has a `loader` hook that runs when opencode instantiates the provider. It calls `ensureFresh()` which:
- Reads auth from `~/.local/share/opencode/auth.json`
- Checks if token is expiring (60s safety window)
- If so, calls `refreshToken()` against the OAuth endpoint
- Calls `listModels()` against the provider API
The `provider.models` hook also calls `listModels()` to discover model metadata. While the plugin has try-catch fallbacks, the error is thrown at a higher level in opencode's startup orchestration before those hooks can gracefully degrade.
Evidence from session database
The SQLite session database (`~/.local/share/opencode/opencode.db`) shows:
- Last successful session: 08:37 BST
- Crash time: 10:16 BST (from debug log timestamp)
- Next session: 20:44 BST (8 hours later)
The crash blocked all opencode usage for ~10.5 hours. The auth token was valid (expires 21 May 10:20 UTC), so this was not a token expiry issue.
Reproduction
- Configure a provider that uses a plugin with a `loader` hook (e.g. `opencode-kimi-full`)
- Make the provider API return 5xx (or have a real outage)
- Start opencode -- it crashes with the error above
Suggested fixes
- Lazy provider initialisation -- don't validate providers at startup; initialise them on first use
- Graceful degradation -- if a provider fails during startup, mark it as unavailable and continue with remaining providers
- Retry with backoff -- add retry logic for transient 5xx errors during startup
- Better error messages -- surface which specific provider failed and why, rather than the generic "Unexpected server error"
Environment
- opencode v1.15.5
- Linux (Pop!_OS)
- Plugin: opencode-kimi-full v1.4.0
- Provider: kimi-for-coding-oauth (OpenAI-compatible via @ai-sdk/openai-compatible)
czmhwyl commented on May 22, 2026 This is because the code format was incorrect when configuring the other API call path. The solution is to clear the opencode.json and auth.json files. thaumkid commented on May 22, 2026 I noticed a similar issue crops up when there is whitespace in my startup path, possibly with certain plugins enabled. seems one solution is to never have spaces in any important paths. ThunderEagle commented on May 24, 2026 I just did a debugging session with opencode and Big Pickle running outside of my project, I only received the error from within the project and only when my opencode.json file included an instructions entry.
Root cause: opencode v1.15.10 has a regression in the instructions file parser — any # character in the instructions file causes the server to crash during initialization (config.providers, provider.list, app.agents, config.get all fail). donwich commented on May 25, 2026 I've run into the same issue. The problem occurs because OpenCode requires Bun to install plugins on startup. LLM told me that Bun has SSL certificate bugs on Windows, which prevent plugins from downloading properly and ultimately fail to launch OpenCode. version:1.15.10 ktulu315 commented on May 26, 2026
(no reinstall needed)
Overwrite both files with an empty JSON object, then re-authenticate. This worked instantly on my machine and preserves sessions, config, plugins, etc.
Thank you, i really solved it because trying that commands i discovered my opencode,jsonc was wrong... if someone need to fit that just edit that file and put this:
location:
C:\Users<USER>.config\opencode
{
"$schema": "https://opencode.ai/config.json"
}
It works for me, thanks Tushar49 commented on May 27, 2026 Opened #29562 to fix this — addresses sub-cause (a) from this thread (the whitespace-only auth.json after an interrupted write that @SimplyJoshi traced).
Root cause matches the diagnosis above: FileSystem.readJson runs JSON.parse synchronously inside an Effect.fn generator, so the SyntaxError becomes an Effect defect that bypasses Effect.orElseSucceed in Auth.all. Every config-dependent request then errors with the generic "Unexpected server error".
The PR wraps JSON.parse in Effect.try returning a typed FileSystemError (matching the existing pattern at filesystem.ts:81), adds an Effect.logWarning before falling back to empty credentials so users can self-diagnose, applies the same recovery to OPENCODE_AUTH_CONTENT, and adds 5 regression tests covering half-written JSON / binary garbage / single-key lookup / set-after-corruption / bad env var.
Out of scope for this PR (kept narrow on purpose):
- Atomic
writeJson to prevent recurrence — being addressed independently in fix(storage): write json files atomically #28010
- Provider-API 5xx graceful degradation (sub-cause b) — bigger arch change
# in instructions parser crash (sub-cause c) — separate bug
Verified locally: bun typecheck clean, 26/26 core filesystem tests + 33/33 opencode auth+filesystem tests pass.
cc @kitlangton (assignee) — happy to rework if a different shape is preferred. dduart3 commented on May 28, 2026
Root cause: auth.json corrupted with whitespace-only contents
I hit this on Windows 11 with opencode 1.15.5 and traced it to a specific failure mode that I think explains every "Ctrl+C while building" / "closed the terminal mid-build" report above. Posting the diagnosis in case it helps the maintainers and the next person who lands here.
What the server is actually crashing on
The TUI-facing error (4 of 5 requests failed: config.providers, provider.list, app.agents, config.get) is downstream noise. The real failure in the server log is a JSON parse error inside Auth.all():
ERROR ... service=server error=JSON Parse error: Unrecognized token ' '
cause=SyntaxError: JSON Parse error: Unrecognized token ' '
at FileSystem.readJson (chunk-y6vv15b7.js)
at Auth.all (chunk-y6vv15b7.js)
at Config.loadInstanceState (chunk-y6vv15b7.js)
at Config.state (chunk-y6vv15b7.js)
at Config.get (chunk-hqfz04v1.js)
Every config-dependent request goes through Config.get -> Config.loadInstanceState -> Auth.all -> readJson(auth.json). When that parse throws, every one of those requests fails with the same generic "Unexpected server error", which is why the user sees four failures instead of one. Logs live at ~/.local/share/opencode/log/*.log (or %USERPROFILE%\.local\share\opencode\log\ on Windows) — searching them for Auth.all surfaces the cause immediately.
What the files looked like
On my machine, both auth.json files existed and were non-empty, but contained only whitespace — no JSON, not a single {:
Path Size Contents
%LOCALAPPDATA%\opencode\auth.json 327 bytes 327 space characters
%USERPROFILE%\.local\share\opencode\auth.json 543 bytes 543 space characters
Both files had identical modification timestamps down to the second.
Why this happens
The byte counts strongly suggest a non-atomic write. The file is opened with O_TRUNC, the buffer is padded with spaces, and the actual JSON payload is supposed to overwrite that padding before the file is closed — but if the process is killed (Ctrl+C, terminal closed, OS shutdown) before the write completes, the file is left at its full size, filled with 0x20. The filesystem still sees a "valid" non-empty file, so nothing flags it as broken.
This matches every report above where the problem started after interrupting opencode while it was "Building". That's the window in which the auth file is being rewritten.
The parser then fails fatally instead of treating an unreadable auth file as "no credentials configured", which traps the user: they cannot open the TUI to run auth login, because the TUI refuses to bootstrap without a parseable auth file. Catch-22.
Recovery (no reinstall needed)
Overwrite both files with an empty JSON object, then re-authenticate. This worked instantly on my machine and preserves sessions, config, plugins, etc.
Windows (PowerShell):
Set-Content "$env:LOCALAPPDATA\opencode\auth.json" '{}'
Set-Content "$env:USERPROFILE.local\share\opencode\auth.json" '{}'
opencode auth login
macOS / Linux:
echo '{}' > "$HOME/.local/share/opencode/auth.json"
also check $XDG_DATA_HOME/opencode/auth.json if you've overridden it
opencode auth login
The "uninstall + nuke .cache, .config, .local/share" workaround posted earlier works because it deletes the corrupted file along with everything else. The targeted fix is just the two auth.json files — no need to lose your sessions, projects, or installed plugins.
Suggested fixes
- Atomic write for
auth.json — write to auth.json.tmp and rename() over auth.json. POSIX rename and Windows MoveFileEx with MOVEFILE_REPLACE_EXISTING are both atomic at the filesystem level: an interrupted process either leaves the old file intact or replaces it with the fully-written new one, never a half-written state. This eliminates the failure mode entirely.
- Lenient parse on read — if
auth.json is empty, whitespace-only, or otherwise malformed, log a warning and treat it as {} rather than crashing the bootstrap. The TUI should always start; an unparseable auth file is a "no providers configured" condition, not a fatal one. Users can then run opencode auth login to recover from inside the app.
- Surface the real cause — the user-facing
4 of 5 requests failed: config.providers... message doesn't mention auth.json or the underlying SyntaxError. Including the offending file path and the parse error in the bootstrap error would let users self-diagnose without grepping log files.
Environment
- opencode 1.15.5
- Windows 11 Pro (build 26200)
- Bun runtime (bundled)
Happy to test a patch or attach more log detail if it helps.
you are my saviour, thank you so much man, this is the way nemesifier commented on May 29, 2026 It happened to me and it's due to recent edits of mine to the opencode.jsonc config file, the cli didn't like the changes and crashes with a very unclear error message. It would be worth making the error message more clear. Reacted by Jacob Samuel Rockowitz antoniofrignani commented on May 29, 2026 happened to me on mac to, resolved with rm -rf ~/.local/share/opencode realsanjeev commented on Jun 2, 2026 Happened to me. deleted the rm -rf ~/.local/share/opencode
and rm -rf ~/.config/opencode.
But didn't work. Uninstalled and installed via bun and npm. Didn't work.
It worked for me when: At last, uninstalled using opencode uninstall.
Then reinstalled opencode using curl -fsSL https://opencode.ai/install | bash. It worked.
It seems there were files in other dir which was causing that issue and opencode uninstall removed that file. sssxks commented on Jun 3, 2026
A workaround solution... Because I keep being unable to start opencode for past weeks.. Is just run HOME=/tmp/opencodetmp123 opencode... Of course it'll not persist your sessions etc using this.
same error for me
Try to uninstall & re-install but same thing .....
FIX : in opencode.jsonc i was using
"agents": {
"context": [
"./AGENTS.md"
]
}
this is not working anymore and crash opencode on version 1.15.0, need to change to
"instructions": ["AGENTS.md"]
yes my issue is also arised from misconfiguration in opencode.jsonc. but the error message is not great. it seems the malformed config is not validated and causes internal error nemesifier commented on Jun 3, 2026 Yesterday I ran into the same issue with claude code: it detected the malformed config file and fixed it on its own. Reacted by Jacob Samuel Rockowitz jsuryakt commented on Jun 4, 2026 In macOS
opencode run shows:
- SQLITE_READONLY on ~/.local/share/opencode/opencode.db
- EACCES creating lock files in ~/.local/state/opencode/locks/...
Run this once to fix ownership:
sudo chown -R "$USER":"$(id -gn)" \
~/.local/state/opencode \
~/.local/share/opencode \
~/.config/opencode
Then restart opencode normally (without sudo):
opencode
If it still fails, remove stale DB/lock files and retry:
rm -f ~/.local/share/opencode/opencode.db{,-wal,-shm}
rm -rf ~/.local/state/opencode/locks
opencode jrockowitz commented on Jun 4, 2026
Yesterday I ran into the same issue with claude code: it detected the malformed config file and fixed it on its own.
Yep, I had manually edited ~/.config/opencode/opencode.json and the JSON was invalid, which triggered this error, and the logs also caught
ERROR 2026-06-04T20:08:15 +3ms service=server ref=err_72f914a1 error=ConfigJsonError cause=ConfigJsonError: ConfigJsonError
Right before the error was
INFO 2026-06-04T20:08:15 +0ms service=config path=/Users/NAME/.config/opencode/opencode.json loading
Anyone seeing this issue should check the most recent log and look for the corrupted *.json file before reinstalling opencode or purging all your config. radoslav06 commented on Jun 5, 2026 The same error, after fixing opencode.json it's working again, but I will never guess that I need to fix the settings without this thread. The error message is quite off. Yangeki commented on Jun 6, 2026 I encountered the same issue, but I was able to fix it by deleting the "telemetry": false configuration item. Adding it back caused the error to reappear.
"telemetry": false Mehdi-afs commented on Jun 8, 2026 it happened to me on mac when i cmd+c in the middle of a review operation.
I fixed it by opening .config/opencode/opencode.json file, and fixing the JSON structure. marcodc74 commented on Jun 8, 2026 Mehdi-afs commented on Jun 9, 2026 today I ran into same problem again, but this time was not because of .config/opencode/opencode.json
opencode was updated to v1.16.2, which changed the permission schema. The global agent config at ~/.config/opencode/agents/agent.md still had the old format:
permission: allow # ❌ old format
The new schema expects a granular object instead:
permission:
read: allow
edit: ask
bash: allow
Took me an hour to debug it with another agent, I wish the erro message opencode gives out would point directly to the file that has issue, is that so hard to implement??
:(( github-actions commented on Aug 9, 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|