GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — models.json cache corruption causes intermittent startup failure for config.providers and provider.list · Issue #30813 · anomalyco/opencode

models.json cache corruption causes intermittent startup failure for config.providers and provider.list #30813

New issue
Copy link
New issue
Copy link
Closed
#30947
Closed
models.json cache corruption causes intermittent startup failure for config.providers and provider.list#30813
#30947
Copy link
Assignees
nexxeln

Description

@AlexPawlicki
AlexPawlicki
opened on Jun 4, 2026
Issue body actions

Bug

opencode fails to start intermittently with:

Error: 2 of 5 requests failed: Unexpected server error. Check server logs for details.
Affected startup requests: config.providers, provider.list

Root Cause (from server logs)

The actual error in the server log is:

ERROR service=server error=JSON Parse error: Unexpected EOF cause=SyntaxError: JSON Parse error: Unexpected EOF
    at ModelsDev.populate
    at Provider.list
    at ConfigHttpApi.providers

~/.cache/opencode/models.json gets corrupted (truncated/empty) if opencode is terminated while writing an updated model catalog to that file. On the next launch, ModelsDev.populate fails to parse the truncated JSON, which causes both config.providers and provider.list to fail, producing the "Unexpected server error" shown to the user.

Steps to Reproduce

  1. While opencode is running, hard-kill the process (e.g. close terminal, kill PID, machine sleep/wake) during a model catalog refresh
  2. Re-launch opencode — it fails with the error above

Expected Behaviour

opencode should handle a corrupted/missing models.json gracefully by re-downloading the model catalog rather than failing startup.

Suggested Fix

Write the updated catalog to a temp file and atomically rename it to models.json, so a mid-write kill cannot leave a partially-written file. Also add a fallback: if readJson throws a parse error on the cache file, delete it and re-fetch rather than propagating the error up to the startup requests.

Environment

  • Platform: Windows 11 (win32)
  • Shell: PowerShell 5.1
  • opencode: 1.15.13

Activity

  1. github-actions
    assigned
    nexxeln
    on Jun 4, 2026
  2. github-actions commented on Jun 4, 2026

    @github-actions
    github-actionsBot
    on Jun 4, 2026 – with GitHub Actions
    Contributor
    More actions

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

    • return {} on json parse error #29366: Same root cause — JSON parse failure in models.json (via models-dev.ts) causing startup failure, with a similar fix suggestion (handle parse errors gracefully rather than propagating them)
    • Error: 4 of 5 requests failed: config.providers: Unexpected server error. #27530: Same user-visible error (config.providers/provider.list startup failure with "Unexpected server error"), though that issue doesn't identify the models.json corruption as the cause
  3. nexxeln
    closed this as completedin #30947on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @nexxeln
    nexxeln

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.