TypeError: undefined is not an object crash on start after v1.0.180 update
Description
After the latest update to v1.0.180, I get the following crash on startup:
{
"name": "UnknownError",
"data": {
"message": "TypeError: undefined is not an object (evaluating 'Provider2.sort(Object.values(item.models))[0].id')\n at <anonymous> (src/server/server.ts:1604:95)\n at o3 (../../node_modules/.bun/[email protected]/node_modules/remeda/dist/chunk-3ZJAREUD.js:1:137)\n at <anonymous> (src/server/server.ts:1604:22)\n at processTicksAndRejections (native:7:39)"
}
}
I have tried to downgrade to different versions of opencode and now only get this error no matter the version.
OpenCode version
v1.0.180
Steps to reproduce
- Install opencode v1.0.180
- Run
opencodeto start a new session - Get this crash
Screenshot and/or share link
No response
Operating System
macOS 15.7.1
Terminal
Ghostty w/ zsh
I've searched through existing issues in this repository and did not find any clear duplicates of this issue. The error you're encountering appears to be unique to the Provider sorting logic in v1.0.180.
However, this is a startup crash issue, so if you've seen similar crashes in the past, you may want to check if any of these startup-related issues contain helpful troubleshooting steps:
- #3537: Custom slash commands can crash opencode on startup
- #3568: "Unexpected EOF" crash immediately after startup
- #5338: Opencode becomes stuck on start if internet connection is not stable
If downgrading to previous versions still causes the crash, it might indicate a configuration corruption. You could try clearing your state directory at ~/.local/state/opencode/tui or your config directory to see if that resolves the issue.
Same I am facing same issues after
bun install bun dev
{
"name": "UnknownError",
"data": {[email protected]
"message": "TypeError: undefined is not an object (evaluating 'Provider.sort(Object.values(item.models))[0].id')\n at
I have also linked this issue in discord.
same here 👍🏽
❯ opencode
{
"name": "UnknownError",
"data": {
"message": "TypeError: undefined is not an object (evaluating 'Provider2.sort(Object.values(item.models))[0].id')\n at
rm -rf ~/.cache/opencode/ helps to run in once then error happens againg
same here, i use oh my opencode extension if its help trace the problem
I get the issue on 1.0.150. It looks like models.json got changed (sidenote: how) to have an invalid schema via some out of band process, which is causing the crash.
rm ~/.cache/opencode/models.json
I had a bad update to models.dev fixed it upstream but if u get this error run this^
rm ~/.cache/opencode/models.json
This is the fix, ty!
Seems to be fixed now from models.dev fix. The issue was with one of the model providers in models.dev not actually including a model. Opencode expects so and crashes otherwise (hence Provider2.sort(Object.values(item.models))[0] being undefined). Not sure if that's type safe?
yeah ill fix that and add test
Same on 1.0.137.
$ opencode --version
1.0.137
$ opencode
{
"name": "UnknownError",
"data": {
"message": "TypeError: undefined is not an object (evaluating 'Provider2.sort(Object.values(item.models))[0].id')\n at <anonymous> (src/server/server.ts:1466:95)\n at o3 (../../node_modules/.bun/[email protected]/node_modules/remeda/dist/chunk-3ZJAREUD.js:1:137)\n at <anonymous> (src/server/server.ts:1466:22)\n at processTicksAndRejections (native:7:39)"
}
}
$ brew info opencode
==> opencode: stable 1.0.182 (bottled)
AI coding agent, built for the terminal
https://opencode.ai
Installed
/opt/homebrew/Cellar/opencode/1.0.137 (10 files, 93.2MB) *
Poured from bottle using the formulae.brew.sh API on 2025-12-09 at 11:03:43
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/opencode.rb
License: MIT
==> Dependencies
Required: node ✔, ripgrep ✔
Yeah just clear your models list and it will be fine^^