TypeError: undefined is not an object crash on start after v1.0.180 update #3698

Closed
opened 2026-02-16 17:41:08 -05:00 by yindo · 14 comments
Owner

Originally created by @tracy-codes on GitHub (Dec 20, 2025).

Originally assigned to: @rekram1-node on GitHub.

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/remeda@2.26.0/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

  1. Install opencode v1.0.180
  2. Run opencode to start a new session
  3. Get this crash

Screenshot and/or share link

No response

Operating System

macOS 15.7.1

Terminal

Ghostty w/ zsh

Originally created by @tracy-codes on GitHub (Dec 20, 2025). Originally assigned to: @rekram1-node on GitHub. ### 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/remeda@2.26.0/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 1. Install opencode v1.0.180 2. Run `opencode` to start a new session 3. Get this crash ### Screenshot and/or share link _No response_ ### Operating System macOS 15.7.1 ### Terminal Ghostty w/ zsh
yindo added the bug label 2026-02-16 17:41:08 -05:00
yindo closed this issue 2026-02-16 17:41:08 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 20, 2025):

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.

@github-actions[bot] commented on GitHub (Dec 20, 2025): 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.
Author
Owner

@korade-krushna commented on GitHub (Dec 20, 2025):

Same I am facing same issues
after

bun install
bun dev

{
"name": "UnknownError",
"data": {client-s3@3.933.0
"message": "TypeError: undefined is not an object (evaluating 'Provider.sort(Object.values(item.models))[0].id')\n at (/Users/krishnakorade/Developer/osp/opencode/packages/opencode/src/server/server.ts:1604:95)\n at o (/Users/krishnakorade/Developer/osp/opencode/node_modules/.bun/remeda@2.26.0/node_modules/remeda/dist/chunk-3ZJAREUD.js:1:137)\n at (/Users/krishnakorade/Developer/osp/opencode/packages/opencode/src/server/server.ts:1604:22)\n at processTicksAndRejections (native:7:39)"
}
}

@korade-krushna commented on GitHub (Dec 20, 2025): Same I am facing same issues after bun install bun dev { "name": "UnknownError", "data": {client-s3@3.933.0 "message": "TypeError: undefined is not an object (evaluating 'Provider.sort(Object.values(item.models))[0].id')\n at <anonymous> (/Users/krishnakorade/Developer/osp/opencode/packages/opencode/src/server/server.ts:1604:95)\n at o (/Users/krishnakorade/Developer/osp/opencode/node_modules/.bun/remeda@2.26.0/node_modules/remeda/dist/chunk-3ZJAREUD.js:1:137)\n at <anonymous> (/Users/krishnakorade/Developer/osp/opencode/packages/opencode/src/server/server.ts:1604:22)\n at processTicksAndRejections (native:7:39)" } }
Author
Owner

@CodingInCarhartts commented on GitHub (Dec 20, 2025):

I have also linked this issue in discord.

@CodingInCarhartts commented on GitHub (Dec 20, 2025): I have also linked this issue in discord.
Author
Owner

@Regboy744 commented on GitHub (Dec 20, 2025):

same here 👍🏽

❯ opencode
{
"name": "UnknownError",
"data": {
"message": "TypeError: undefined is not an object (evaluating 'Provider2.sort(Object.values(item.models))[0].id')\n at (src/server/server.ts:1604:95)\n at o3 (../../node_modules/.bun/remeda@2.26.0/node_modules/remeda/dist/chunk-3ZJAREUD.js:1:137)\n at (src/server/server.ts:1604:22)\n at processTicksAndRejections (native:7:39)"
}
}

@Regboy744 commented on GitHub (Dec 20, 2025): same here 👍🏽 ❯ 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:1604:95)\n at o3 (../../node_modules/.bun/remeda@2.26.0/node_modules/remeda/dist/chunk-3ZJAREUD.js:1:137)\n at <anonymous> (src/server/server.ts:1604:22)\n at processTicksAndRejections (native:7:39)" } }
Author
Owner

@moddi3 commented on GitHub (Dec 20, 2025):

rm -rf ~/.cache/opencode/ helps to run in once
then error happens againg

@moddi3 commented on GitHub (Dec 20, 2025): rm -rf ~/.cache/opencode/ helps to run in once then error happens againg
Author
Owner

@azizikri commented on GitHub (Dec 20, 2025):

same here, i use oh my opencode extension if its help trace the problem

@azizikri commented on GitHub (Dec 20, 2025): same here, i use oh my opencode extension if its help trace the problem
Author
Owner

@otisdog8 commented on GitHub (Dec 20, 2025):

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.

@otisdog8 commented on GitHub (Dec 20, 2025): 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.
Author
Owner

@rekram1-node commented on GitHub (Dec 20, 2025):

rm ~/.cache/opencode/models.json

@rekram1-node commented on GitHub (Dec 20, 2025): rm ~/.cache/opencode/models.json
Author
Owner

@rekram1-node commented on GitHub (Dec 20, 2025):

I had a bad update to models.dev fixed it upstream but if u get this error run this^

@rekram1-node commented on GitHub (Dec 20, 2025): I had a bad update to models.dev fixed it upstream but if u get this error run this^
Author
Owner

@tracy-codes commented on GitHub (Dec 20, 2025):

rm ~/.cache/opencode/models.json

This is the fix, ty!

@tracy-codes commented on GitHub (Dec 20, 2025): > rm ~/.cache/opencode/models.json This is the fix, ty!
Author
Owner

@SimHoZebs commented on GitHub (Dec 20, 2025):

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?

@SimHoZebs commented on GitHub (Dec 20, 2025): 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?
Author
Owner

@rekram1-node commented on GitHub (Dec 20, 2025):

yeah ill fix that and add test

@rekram1-node commented on GitHub (Dec 20, 2025): yeah ill fix that and add test
Author
Owner

@vanyauhalin commented on GitHub (Dec 21, 2025):

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/remeda@2.26.0/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 ✔
@vanyauhalin commented on GitHub (Dec 21, 2025): Same on 1.0.137. ```sh $ 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/remeda@2.26.0/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 ✔ ```
Author
Owner

@rekram1-node commented on GitHub (Dec 22, 2025):

Yeah just clear your models list and it will be fine^^

@rekram1-node commented on GitHub (Dec 22, 2025): Yeah just clear your models list and it will be fine^^
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3698