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 — pm-dispatch(opencode): auth-file and API-response JSON parsed unguarded — null/malformed state file escapes as raw Type/SyntaxError, non-string password silently coerced into the credential · Issue #7085 · developing-today/code

pm-dispatch(opencode): auth-file and API-response JSON parsed unguarded — null/malformed state file escapes as raw Type/SyntaxError, non-string password silently coerced into the credential #7085

New issue
Copy link
New issue
Copy link
Closed
#7088
Closed
pm-dispatch(opencode): auth-file and API-response JSON parsed unguarded — null/malformed state file escapes as raw Type/SyntaxError, non-string password silently coerced into the credential#7085
#7088
Copy link
Labels
app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Description

@dezren39
dezren39
opened on Nov 8, 2026
Issue body actions

Problem

pm-stack/dispatch/src/opencode.ts — the dispatch service's only client for the laptop OpenCode server — parses two JSON inputs with bare JSON.parse + a type cast, outside any guard, so wrong-shape or malformed input escapes as raw TypeError/SyntaxError instead of the module's own OpenCodeError (the error type that carries the client's 502 semantics), and a non-string password is silently coerced into the live Basic credential.

Evidence (verified this run, laptop primary main 0d75b17aab, real module md5 fd102fcacafd2a3ddb3d05dfe906c66f)

  • authHeader() (opencode.ts:18-27): the try/catch guards only readFile (:19-24). Line 25 is const data = JSON.parse(raw) as { password?: string } — outside the guard, cast-only. Line 26 checks truthiness only, never the type.

  • api() (opencode.ts:44): const parsed: unknown = JSON.parse(text) on a 2xx response is likewise unguarded.

  • Probe (laptop ~/git/fleet/probe-dispatch-opencode/, real opencode.ts verbatim + a stub OpenCode server; createSession drives authHeader + api):

    Case Observed
    control {"password":"pw123"} + {"data":{"id":…}} resolves, session id returned
    control {} (no password) OpenCodeError: opencode auth file carries no password (the intended vocabulary)
    auth file null raw TypeError: null is not an object (evaluating 'data.password') — not an OpenCodeError
    auth file {not json (truncated/mid-write state file) raw SyntaxError: JSON Parse error — not an OpenCodeError
    auth file {"password":12345} request succeeds: the number is string-coerced into the Authorization: Basic credential
    auth file {"password":{"x":1}} request succeeds: the credential sent is the literal [object Object] string
    valid auth + HTTP 200 non-JSON body (<html>…, e.g. the wrong service answering on the OpenCode port) raw SyntaxError: JSON Parse error: Unrecognized token '<' — not an OpenCodeError
  • There is no test file for this client at all: pm-stack/dispatch/test/ covers auth/config/packet/queue/server/validate/launch_*, but no opencode.test.ts exists.

Why it matters

  • The auth file is the OpenCode server's own state file (service-prod.json, config.ts opencodeAuthFile), read on every API call. A truncated or mid-write read, a hand-edited file, or a schema drift in what the server writes turns every dispatch launch into a raw crash whose message names no file and no cause; the dispatch handler (server.ts) only special-cases Auth/Validation/Queue errors, so these surface as generic 500s / launch-failure notes instead of the client's diagnosable 502 shape.
  • A non-string password never errors at the boundary at all: dispatch silently authenticates with a coerced garbage credential and the failure appears downstream as an OpenCode 401, blamed on the server rather than on the state file's shape.
  • This is the same boundary-validation contract sibling dispatch modules already keep (validate.ts validates every request field; queue.ts checks the RPC row's id type; createSession itself validates the returned session id at opencode.ts:61-64) — the auth file and the 2xx body are the two unguarded doors in the same file.

Acceptance criteria

  • authHeader(): malformed JSON, a non-object document (null/array/scalar), and a missing, non-string, or empty password all throw OpenCodeError naming the auth file / the shape problem — never a raw TypeError/SyntaxError, and a non-string password is never coerced into a credential.
  • api(): a 2xx response whose body is not valid JSON throws OpenCodeError naming the method/path — never a raw SyntaxError.
  • A new pm-stack/dispatch/test/opencode.test.ts pins all of the probe cases above (valid control still resolves; {} control still yields the existing no-password OpenCodeError).
  • Existing dispatch suite still passes (bun test in pm-stack/dispatch).

Found by new-issue-creator-code-b (Lane B), run 2026-11-07 20:50 CST. Dedup: searched open + closed issues for OpenCodeClient / "opencode auth" / dispatch opencode parsing — no existing issue covers this client; #3009 (orphaned session) and #3010 (body-cap units) are different defects in different files.

Activity

  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    status/in-progressQueue worker lifecycle state
    source/creatorFiled by the new-issue-creator job
    on Nov 8, 2026
  2. developing-today commented on Nov 8, 2026

    @developing-today
    developing-todayBot
    on Nov 8, 2026 – with developing.today
    Contributor
    More actions

    CODE-2241

  3. dezren39
    added
    priority/normalOrdinary priority (the default)
    work/self-assignedAn agent grabbed this item directly, outside the queue
    effort/xsTrivial: expected under 30 minutes of work
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 8, 2026
  4. dezren39 commented on Nov 8, 2026

    @dezren39
    dezren39
    on Nov 8, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-b (Lane B)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-07 20:50 CST
    • Found via: filed this run
    • Task: Filed after laptop verification (probe ~/git/fleet/probe-dispatch-opencode, real opencode.ts md5 fd102fcacafd2a3ddb3d05dfe906c66f @0d75b17aab): null auth file -> raw TypeError, malformed -> raw SyntaxError, non-string password coerced into the Basic credential, non-JSON 200 -> raw SyntaxError; {} control correctly yields OpenCodeError.
    • Expectation: effort/xs — boundary validation in opencode.ts + a new opencode.test.ts pinning the probe cases.
    • Links: n/a
  5. dezren39 commented on Nov 8, 2026

    @dezren39
    dezren39
    on Nov 8, 2026
    MemberAuthor
    More actions

    🤖 Agent note · picked up

    • Agent: new-issue-creator-code-b (Lane B)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-07 20:50 CST
    • Found via: self-assigned during new-issue-creator-code-b run (guarded self-solve, lifecycle protocol §4: filed this run, trivial, no safety labels)
    • Task: Fix opencode.ts boundary parsing (auth file + 2xx JSON body -> OpenCodeError; string-only password) and add test/opencode.test.ts, on branch creator-b/7085-opencode-parse, in a laptop worktree.
    • Expectation: effort/xs — done = targeted tests pass on the laptop, PR opened and merged with checks green.
    • Links: branch creator-b/7085-opencode-parse (pending)
  6. developing-today
    added
    status:in-review
    on Nov 8, 2026
  7. dezren39
    added a commit that references this issue on Nov 8, 2026

    Merge pull request #7088 from developing-today/creator-b/7085-opencod…

    d94e6c7
  8. dezren39
    closed this as completedin #7088on Nov 8, 2026
  9. developing-today
    added
    status:done
    and removed
    status:in-review
    on Nov 8, 2026
  10. dezren39 commented on Nov 8, 2026

    @dezren39
    dezren39
    on Nov 8, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done

    • Agent: new-issue-creator-code-b (Lane B)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-07 20:50 CST
    • Found via: self-assigned during new-issue-creator-code-b run
    • Task: Fixed and merged. PR fix(dispatch): validate opencode auth-file and response JSON at the boundary (#7085) #7088 merged as d94e6c7: authHeader() now throws OpenCodeError for malformed JSON / non-object auth documents and requires a non-empty string password (no coercion); api() throws OpenCodeError on a non-JSON 2xx body. New test/opencode.test.ts (8 tests) pins every probe case.
    • Expectation: met — new tests 8/8 on branch and 5 fail pre-fix; full dispatch suite 139/139 on the branch and re-verified 139/139 on merged main d94e6c7 (laptop). PR CI was pending (queued) at merge, per the standing merge directive.
    • Links: PR fix(dispatch): validate opencode auth-file and response JSON at the boundary (#7085) #7088 (merged d94e6c7); probe ~/git/fleet/probe-dispatch-opencode (laptop)
  11. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    work/self-assignedAn agent grabbed this item directly, outside the queue
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    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.