Release macro of models.dev json broken in release bundle #6930

Closed
opened 2026-02-16 18:05:38 -05:00 by yindo · 2 comments
Owner

Originally created by @MMunier on GitHub (Jan 20, 2026).

Originally assigned to: @thdxr on GitHub.

Description

https://github.com/anomalyco/opencode/commit/d71153eae6c3218e45c6a32ca7becd4b13ae9414 breaks the models.dev json embedded in the release executable.

The release build has the data call, defined by the macro in https://github.com/anomalyco/opencode/blob/616329ae97c975f21687f6c8c9c6d4d8018e6fd9/packages/opencode/src/provider/models-macro.ts already resolved, however only in the actual call site.

This results in the following function being embedded in the binary, with the literal sting present in the assignment to json3:

    async function get() {
      refresh();
      const file2 = Bun.file(filepath);
      const result = await file2.json().catch(() => {});
      if (result)
        return result;
      if (typeof data === "function") {
        const json3 = await '{"privatemode-ai": ...'
        return JSON.parse(json3);
      }
      const json2 = await fetch("https://models.dev/api.json").then((x) => x.text());
      return JSON.parse(json2);
    }

However, since data is now undefined this branch can never be taken and thus the binary always falls back to fetching, even if the data is present in the binray itself, and refresh is forcibly skipped by the environment variable OPENCODE_DISABLE_MODELS_FETCH.

Plugins

No response

OpenCode version

No response

Steps to reproduce

Download the release, and search for the code.
I used vim and searched for either OPENCODE_DISABLE_MODELS_FETCH or models.dev respectively

Screenshot and/or share link

No response

Operating System

ubuntu 24.04

Terminal

alacritty

Originally created by @MMunier on GitHub (Jan 20, 2026). Originally assigned to: @thdxr on GitHub. ### Description https://github.com/anomalyco/opencode/commit/d71153eae6c3218e45c6a32ca7becd4b13ae9414 breaks the models.dev json embedded in the release executable. The release build has the data call, defined by the macro in https://github.com/anomalyco/opencode/blob/616329ae97c975f21687f6c8c9c6d4d8018e6fd9/packages/opencode/src/provider/models-macro.ts already resolved, however only in the actual call site. This results in the following function being embedded in the binary, with the literal sting present in the assignment to json3: ```ts async function get() { refresh(); const file2 = Bun.file(filepath); const result = await file2.json().catch(() => {}); if (result) return result; if (typeof data === "function") { const json3 = await '{"privatemode-ai": ...' return JSON.parse(json3); } const json2 = await fetch("https://models.dev/api.json").then((x) => x.text()); return JSON.parse(json2); } ``` However, since data is now undefined this branch can never be taken and thus the binary always falls back to fetching, even if the data is present in the binray itself, and refresh is forcibly skipped by the environment variable OPENCODE_DISABLE_MODELS_FETCH. ### Plugins _No response_ ### OpenCode version _No response_ ### Steps to reproduce Download the release, and search for the code. I used vim and searched for either `OPENCODE_DISABLE_MODELS_FETCH` or `models.dev` respectively ### Screenshot and/or share link _No response_ ### Operating System ubuntu 24.04 ### Terminal alacritty
yindo added the bug label 2026-02-16 18:05:38 -05:00
yindo closed this issue 2026-02-16 18:05:38 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8860: loading models.dev in built artifacts

This appears to be reporting the same underlying issue caused by the same commit (d71153eae6) that broke bun macro inlining in release builds.

Additionally, these related issues describe the symptoms and impacts of this bug:

  • #9493: Opencode quits/hangs when models.dev not responding
  • #8830: Cannot use opencode in private network
  • #4959: [FEATURE]: Add option to disable models.dev fetch for corporate proxy environments

Feel free to ignore if this addresses a different aspect of the issue.

@github-actions[bot] commented on GitHub (Jan 20, 2026): This issue might be a duplicate of existing issues. Please check: - #8860: loading models.dev in built artifacts This appears to be reporting the same underlying issue caused by the same commit (d71153eae6c3218e45c6a32ca7becd4b13ae9414) that broke bun macro inlining in release builds. Additionally, these related issues describe the symptoms and impacts of this bug: - #9493: Opencode quits/hangs when models.dev not responding - #8830: Cannot use opencode in private network - #4959: [FEATURE]: Add option to disable models.dev fetch for corporate proxy environments Feel free to ignore if this addresses a different aspect of the issue.
Author
Owner

@MMunier commented on GitHub (Jan 20, 2026):

Whoops github actions is correct, This is a duplicate of #8860.

@MMunier commented on GitHub (Jan 20, 2026): Whoops github actions is correct, This is a duplicate of #8860.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6930