opencode icon indicating copy to clipboard operation
opencode copied to clipboard

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

Open tracy-codes opened this issue 4 days ago • 14 comments

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

  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

tracy-codes avatar Dec 20 '25 20:12 tracy-codes

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] avatar Dec 20 '25 20:12 github-actions[bot]

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 (/Users/krishnakorade/Developer/osp/opencode/packages/opencode/src/server/server.ts:1604:95)\n at o (/Users/krishnakorade/Developer/osp/opencode/node_modules/.bun/[email protected]/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 avatar Dec 20 '25 20:12 korade-krushna

I have also linked this issue in discord.

CodingInCarhartts avatar Dec 20 '25 20:12 CodingInCarhartts

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/[email protected]/node_modules/remeda/dist/chunk-3ZJAREUD.js:1:137)\n at (src/server/server.ts:1604:22)\n at processTicksAndRejections (native:7:39)" } }

Regboy744 avatar Dec 20 '25 20:12 Regboy744

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

moddi3 avatar Dec 20 '25 20:12 moddi3

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

azizikri avatar Dec 20 '25 20:12 azizikri

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 avatar Dec 20 '25 20:12 otisdog8

rm ~/.cache/opencode/models.json

rekram1-node avatar Dec 20 '25 20:12 rekram1-node

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

rekram1-node avatar Dec 20 '25 20:12 rekram1-node

rm ~/.cache/opencode/models.json

This is the fix, ty!

tracy-codes avatar Dec 20 '25 20:12 tracy-codes

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 avatar Dec 20 '25 20:12 SimHoZebs

yeah ill fix that and add test

rekram1-node avatar Dec 20 '25 20:12 rekram1-node

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 ✔

vanyauhalin avatar Dec 21 '25 09:12 vanyauhalin

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

rekram1-node avatar Dec 22 '25 06:12 rekram1-node