Repository navigation
Description
opencode-acp-adapter: --server value is never validated — a trailing --server silently talks to the default serve, --server= / a flag-like value loop forever on "Failed to parse URL", and a typo'd flag is silently ignored
Summary
bin/opencode-acp-adapter.mjs takes its one operator flag, --server, with no validation at all. In parseServerUrl (lines 64–76 at def55caf48):
function parseServerUrl(argv) {
let server = process.env.OPENCODE_ACP_SERVER || 'http://127.0.0.1:13420';
for (let i = 0; i < argv.length; i += 1) {
if (argv[i] === '--server' && argv[i + 1]) {
server = argv[i + 1];
i += 1;
} else if (argv[i].startsWith('--server=')) {
server = argv[i].slice('--server='.length);
}
}
return server.replace(/\/+$/, '');
}- A trailing
--serverfails theargv[i + 1]truthiness check and is silently dropped — the adapter talks to the defaulthttp://127.0.0.1:13420serve (or the env var) instead of the server the operator meant to name, with no warning anywhere. --server=setsserverto the empty string. Every request becomes a relative URL: the event stream (runEventStream, lines 226–257) logsFailed to parse URL from /api/event; reconnectingand retries every 1s forever, and session calls fail the same way — yet ACPinitializestill succeeds, so the gateway sees a healthy agent whose every session is broken.- A flag-like value (
--server --bogus-flag) is consumed verbatim as the URL:Failed to parse URL from --bogus-flag/api/event; reconnecting, same infinite loop. - A typo'd flag (
--sever http://127.0.0.1:9) matches nothing in the loop and is silently ignored — again the default serve, no signal.
parseServerUrl is not exported and has no unit coverage: bin/opencode-acp-adapter.test.mjs only ever passes a well-formed --server http://127.0.0.1:<port> (line 105).
Evidence (verified this run, laptop, origin/main def55caf484833e062247c46e5b0c4bb719accd3)
Probe ~/git/fleet/probe-acp-server-arg/ — the real module on the laptop primary (md5 bd0bdaccb8c47bd031bb82a6b8149d08), driven over stdio JSON-RPC (initialize + session/new) with OPENCODE_ACP_ADAPTER_DEBUG=1; the startup debug line prints the resolved serverBase:
| Invocation | Observed |
|---|---|
control: --server http://127.0.0.1:9 |
started; server=http://127.0.0.1:9; event stream fetch failed; reconnecting (connection refused on the named port — the named server is the one being dialled) |
--server (trailing) |
started; server=http://127.0.0.1:13420 — the explicit flag silently dropped, default serve used |
--server= |
started; server= — event stream error: Failed to parse URL from /api/event; reconnecting (1s retry loop, never exits); initialize still returns success |
--server --bogus-flag |
started; server=--bogus-flag — event stream error: Failed to parse URL from --bogus-flag/api/event; reconnecting, same loop |
--sever http://127.0.0.1:9 (typo) |
started; server=http://127.0.0.1:13420 — unknown flag silently ignored, default serve used |
Why it matters
This adapter is the bridge between the ACP gateway (acpx/OpenClaw) and the standing OpenCode serve: prompts, sessions, and the server password resolved in serverPassword() all go to whatever serverBase resolves to. Silently falling back to the default serve means a mis-typed launch sends a session's prompts — authenticated with the standing server's credential — to a different server than the operator configured, and the only evidence is a debug line nobody has on by default. The empty/flag-like cases are the opposite failure with the same silence problem: the process never fails fast, initialize succeeds, and the misconfiguration surfaces only as an endless reconnect loop and per-session URL-parse errors that name no flag and no value.
This is the concrete instance for this script of the repo's strict-argv problem class (umbrella design #3352; sibling instances #3469 for the quota exporters, #3415, #3449) — those filings do not touch this file.
Acceptance criteria
-
--serverwith a missing (trailing), empty (--server=or--server ""), or flag-like (--…) value fails fast at startup: a usage error on stderr naming the flag and the offending value, non-zero exit, before the event stream starts and before any ACP traffic is served. - A
--servervalue that is not a parseablehttp:/https:URL fails the same way at startup — never as a per-requestFailed to parse URLreconnect loop. - The valid forms keep working unchanged:
--server <url>,--server=<url>, trailing slashes stripped,OPENCODE_ACP_SERVERenv fallback, and the built-in default when neither is given. - Regression tests in
bin/opencode-acp-adapter.test.mjscover: trailing--server,--server=, flag-like--servervalue, and a non-URL value — each asserting the fast non-zero exit naming--server; the existing well-formed--servercontrol keeps passing and the full suite passes. - Unknown-argument handling (e.g. the
--severtypo) follows the contract chosen under Design: unknown means stop — one strict argument contract for the repo's operator scripts #3352 — at minimum it must not silently change which server is dialled without a stderr signal.
Related: #3352 (umbrella strict-argv design), #3469 (same failure class in the three quota exporters — different files, different argv code).
Activity
developing-today commentedon Nov 7, 2026
CODE-2187
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
--servervalue inbin/opencode-acp-adapter.mjsparseServerUrl— fail fast at startup on a trailing/empty/flag-like/non-URL value instead of silently dialling the default serve or looping on URL-parse errors.bin/opencode-acp-adapter.test.mjs.~/git/fleet/probe-acp-server-arg(laptop); related issue Design: unknown means stop — one strict argument contract for the repo's operator scripts #3352, issue pm-stack(quota-exporters): opt() in all three exporters takes a flag token as a value — '--out-dir --cdp-port 19222' writes the export into a directory named '--cdp-port', the flag token is consumed twice, and a non-numeric --cdp-port becomes a NaN CDP outage #3469dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
15 remaining items
dezren39 commentedon Nov 9, 2026
🤖 Agent note · picked up — Agent: queue worker (repo-worker-code), lane code-n — Session/ID: task 11326, repo-queue-worker-shift-n 2026-11-09 run. Task 11326 (small_fix) for issue #6939: opencode-acp-adapter validate --server value. Fresh check: issue #6939 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels. Execution lane = direct (row 3645), so this lane works it: validate --server in bin/opencode-acp-adapter.mjs per the issue acceptance criteria, with regression tests.
fix(acp-adapter): validate --server at startup (#6939) (#8054)
dezren39 commentedon Nov 9, 2026
🤖 Agent note · done — Agent: queue worker (repo-worker-code), lane code-n — Session/ID: task 11326, repo-queue-worker-shift-n 2026-11-09 run. Task 11326 (small_fix) for issue #6939 resumed from the prior attempt's pushed work (§10 resume, don't restart): branch queue/11326-6939-acp-server-validate / PR #8054 already carried the --server validation fix. Verified fresh this shift: node --test bin/opencode-acp-adapter.test.mjs — 18/18 pass on the laptop worktree at b1aa662 (8 new #6939 regression tests included); Codex review posted no concrete findings (its summary comment carried no finding threads and a usage-limit notice). Merged PR #8054 (squash) — merge sha b236b1d; issue #6939 CLOSED.