Skip to content

One unreachable well-known origin hides every other integration #46187

Open

Description

@ryanskidmore

Description

If one origin in wellknown:sources stops resolving, every other one is lost too.

WellKnown.load() resolves origins with a fail-fast Effect.forEach, so a single unreachable origin fails the whole batch. opencode.wellknown calls that via Effect.orDie (packages/core/src/wellknown/plugin.ts:13), so the plugin dies before registering its transform and no well-known integration gets registered. Config.loadWellknown catches the same failure and substitutes [], so the remote config for the healthy origins disappears at the same time.

The auth error is misleading, because wellknown.add only fetches the one origin you passed and genuinely succeeds:

◇  Authentication provider discovered
■  Integration not found: https://opencode.example.com

It only shows up after a restart. load() reuses the in-memory cache, so a long-running service keeps working until it cold-loads — which makes it look like whatever version you just installed caused it.

I hit this when a teammate's preview deployment was torn down while still listed in my sources.

OpenCode version

0.0.0-beta-18684

Steps to reproduce

  1. bun run packages/core/script/wellknown-server.ts (listens on 127.0.0.1:8787)
  2. opencode2 auth login http://127.0.0.1:8787 --standalone --method __probe__ — resolves fine, reports Available: login
  3. Add an origin that does not resolve:
    sqlite3 ~/.local/share/opencode/opencode.db \
      "UPDATE kv SET value=json_insert(value,'\$[#]','https://dead-preview.invalid') WHERE key='wellknown:sources';"
  4. Repeat step 2 → Integration not found: http://127.0.0.1:8787

Removing the dead origin restores it. There's currently no command to do that — WellKnown.remove() exists but nothing reaches it, so wellknown:sources only grows.

Operating System

macOS 26.0.1

Terminal

Ghostty

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I can confirm this.

    The exact build you reported (0.0.0-beta-18684) isn't on npm, so I used @opencode/[email protected]:

    1. Started packages/core/script/wellknown-server.ts.
    2. Ran opencode auth login http://127.0.0.1:8787 --standalone --method __probe__. It resolves the integration (Available: login).
    3. Added https://dead-preview.invalid to wellknown:sources.
    4. Ran the same login again. It fails with Integration not found: http://127.0.0.1:8787.

    Removing the dead origin makes it work again. The latest dev (06d3c06), run from source, behaves the same way. The fail-fast Effect.forEach in WellKnown.load() and the Effect.orDie in the well-known plugin are both still there. The script below reproduces it, using a separate data directory so your real database isn't touched.

    Related:

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Repro for #46187: one unreachable well-known origin hides every other integration.
    # Needs: the well-known example server running (bun run packages/core/script/wellknown-server.ts, 127.0.0.1:8787)
    # Set OC="<command>" to run a different opencode (default: opencode from PATH). From a source checkout:
    #   BUN_OPTIONS="--conditions=browser --preload=$PWD/packages/tui/node_modules/@opentui/solid/scripts/preload.js" \
    #   OC="bun $PWD/packages/cli/src/index.ts" /path/to/repro.sh
    # Expected: step 3 prints "Authentication method not found: __probe__. Available: login" (the healthy origin is found).
    # Actual:   step 3 prints "Integration not found: http://127.0.0.1:8787".
    set -u
    OC=${OC:-opencode}
    export XDG_DATA_HOME=$(mktemp -d) XDG_CONFIG_HOME=$(mktemp -d) XDG_CACHE_HOME=$(mktemp -d) XDG_STATE_HOME=$(mktemp -d)
    cd "$(mktemp -d)"
    DB="$XDG_DATA_HOME/opencode/opencode.db"
    sql() { local DB="$XDG_DATA_HOME/opencode/opencode.db"; [ -s "$XDG_DATA_HOME/opencode/opencode-local.db" ] && DB="$XDG_DATA_HOME/opencode/opencode-local.db"  # source builds use opencode-local.db
      bun -e 'import {Database} from "bun:sqlite"; const d=new Database(process.argv[1]); const r=d.query(process.argv[2]).all(); if(r.length) console.log(JSON.stringify(r))' "$DB" "$1"; }
    
    echo "== 1. healthy origin only"
    $OC auth login http://127.0.0.1:8787 --standalone --method __probe__ </dev/null 2>&1 | tail -5
    echo "-- wellknown:sources:"; sql "SELECT value FROM kv WHERE key='wellknown:sources';"
    
    echo "== 2. add an origin that never resolves"
    sql "UPDATE kv SET value=json_insert(value,'\$[#]','https://dead-preview.invalid') WHERE key='wellknown:sources';"
    sql "SELECT value FROM kv WHERE key='wellknown:sources';"
    
    echo "== 3. same login again (cold start)"
    $OC auth login http://127.0.0.1:8787 --standalone --method __probe__ </dev/null 2>&1 | tail -5
    
    echo "== 4. remove the dead origin again"
    sql "UPDATE kv SET value='[\"http://127.0.0.1:8787\"]' WHERE key='wellknown:sources';"
    $OC auth login http://127.0.0.1:8787 --standalone --method __probe__ </dev/null 2>&1 | tail -5

    Run it: bash repro.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions