Opencode should fall back to cached well-known config when endpoint is temporarily unavailable #7795

Open
opened 2026-02-16 18:08:15 -05:00 by yindo · 0 comments
Owner

Originally created by @MaxMiksa on GitHub (Jan 28, 2026).

Originally assigned to: @thdxr on GitHub.

Description

If a user has a wellknown credential configured, Config.get() fetches <url>/.well-known/opencode during startup. If that endpoint is temporarily unavailable (e.g. 500, network hiccup, timeout), Opencode fails to start because config loading hard-throws.

This makes org/enterprise setups brittle: a transient config outage bricks the CLI/agent even if local/project config could still be used.

Suggested fix

  • Cache the last successful well-known config payload locally (e.g. XDG cache).
  • On fetch failure, fall back to the cached config (with a warning) instead of hard-failing.
  • Add a configurable fetch timeout (e.g. OPENCODE_WELLKNOWN_TIMEOUT_MS).

Steps to reproduce

  1. Configure a well-known credential (e.g. via opencode auth login <url>).
  2. Ensure <url>/.well-known/opencode becomes unavailable (500 / offline) after a successful run.
  3. Start Opencode again.

Expected

Opencode starts and uses the cached well-known config (and logs a warning).

Actual

Opencode throws failed to fetch remote config from <url>: <status> during config load and exits.

Environment

  • OS: Windows 11 (also affects any OS on transient network failures)
  • Terminal: Windows Terminal
Originally created by @MaxMiksa on GitHub (Jan 28, 2026). Originally assigned to: @thdxr on GitHub. ### Description If a user has a `wellknown` credential configured, `Config.get()` fetches `<url>/.well-known/opencode` during startup. If that endpoint is temporarily unavailable (e.g. 500, network hiccup, timeout), Opencode fails to start because config loading hard-throws. This makes org/enterprise setups brittle: a transient config outage bricks the CLI/agent even if local/project config could still be used. ### Suggested fix - Cache the last successful well-known `config` payload locally (e.g. XDG cache). - On fetch failure, fall back to the cached config (with a warning) instead of hard-failing. - Add a configurable fetch timeout (e.g. `OPENCODE_WELLKNOWN_TIMEOUT_MS`). ### Steps to reproduce 1. Configure a well-known credential (e.g. via `opencode auth login <url>`). 2. Ensure `<url>/.well-known/opencode` becomes unavailable (500 / offline) after a successful run. 3. Start Opencode again. ### Expected Opencode starts and uses the cached well-known config (and logs a warning). ### Actual Opencode throws `failed to fetch remote config from <url>: <status>` during config load and exits. ### Environment - OS: Windows 11 (also affects any OS on transient network failures) - Terminal: Windows Terminal
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7795