Repository navigation
Description
Problem
pm-stack/dispatch/src/github.ts — the GitHub App client every pm-dispatch session/task launch uses to create its tracking issue, verify attach targets, comment, and label — reads every GitHub API response body through a bare TypeScript cast and never validates the shape. A wrong-shape 200/201 from the API (or any intermediary that answers 2xx with an unexpected body) is silently trusted:
github.ts:104-105— the installation lookup:const data = (await res.json()) as { id: number }; installationId = data.id;github.ts:110-112— the access-token mint:const data = (await res.json()) as { token: string; expires_at: string };the token is cached and returned unvalidated.github.ts:183-184— issue creation:const data = (await res.json()) as { number: number; html_url: string }; return { number: data.number, url: data.html_url };github.ts:230-241— issue lookup (getIssue): the same cast for{ number, state, html_url, pull_request? }.
This is the dispatch sibling of the projector GitHub client fixed in #6954 ("a token-less access-token reply is returned as a valid app token") and of the dispatch OpenCode client fixed in #7085 — this module was never given the same boundary. test/attach_verify.test.ts exercises getIssue only with well-formed bodies and a 404; no test feeds the client a wrong-shape 2xx.
Evidence (verified this run)
Probe on the laptop, ~/git/fleet/probe-dispatch-github (probe.ts, probe2.ts): the real src/github.ts copied verbatim (md5 90762430977c01650312e325510c915a on both sides, current main bfa5caede7622a9e3dee01beeec110e2c5fde2bf), fetch stubbed in the style of test/attach_verify.test.ts, and a fake gh first in PATH so the CLI fallback is deterministic. Control cases pass: a well-formed installation/token/create sequence returns { number: 123, url: "…/issues/123" }, and a well-formed lookup returns the issue.
With a wrong-shape 2xx, the client does not raise a boundary error:
- Installation
{}→ the token mint is POSTed to/app/installations/undefined/access_tokens(the undefined id used verbatim) and the flow "succeeds". - Access-token
{}→ issue creation proceeds with the headerAuthorization: Bearer undefinedand is reported as success (the probe stub recordsauthIsUndefined: trueon the create call). A numeric token ({ token: 123, … }) is likewise coerced and sent asBearer 123. A badexpires_atis cached asexpiresAt: NaN. - Create-issue
{}→createIssuereturns{}— i.e.{ number: undefined, url: undefined }— as a success. Downstream (src/server.ts) that phantom ref feedscanonicalDedupeKey(kind, repo, issue.number), the agent-notecomment(repo, issue.number, …)andaddLabels(repo, issue.number, …)calls, and the 201 response'sissue_number— all against an issue that was never identified. - Create-issue
{ number: "abc", html_url: 42 }→ returned verbatim as{ number: "abc", url: 42 }. - Lookup
{}→getIssuereturns a non-null info withnumber/state/urlallundefined(onlyisPullRequest: falsesurvives serialization). The fix(pm-dispatch): POST /v1/tasks issue_number attach never verifies the issue exists, is open, or is an issue #3007 attach verification then rejects the target withissue #<n> … is undefined, not open— a live, open issue refused on a fabricated state. - JSON
nullbodies (installation, token, create, lookup) → a rawTypeError(null is not an object (evaluating 'data.token')/'data.number'/'(await res.json()).id') escapes the parse site, is caught only by the generic app-route fallback, and is misreported as a dual-route failure ("issue create failed via app (…) and via gh (…)"). For issue creation this is worse than a confusing error: the app POST may already have created the issue server-side before its body failed to parse, and the fallback then creates a second tracking issue viagh.
Why it matters
pm-dispatch is the fleet's launch door: every dispatched session/task anchors its queue packet, dedupe key, agent-note comment, and labels to the issue identity this client returns. A single malformed 2xx can (a) send a literal Bearer undefined credential, (b) anchor a real queue task to a phantom undefined issue, (c) reject a valid attach target as "undefined, not open", or (d) duplicate the tracking issue across the app and gh routes. The failure mode is silent or misattributed in every case — nothing in the response tells the operator the GitHub reply itself was malformed.
Acceptance criteria
- Every
res.json()body inpm-stack/dispatch/src/github.ts(installation lookup, access-token mint, issue create, issue lookup) is validated before use: the body must be a JSON object;ida positive integer;tokena non-empty string with a parseableexpires_at; create/lookupnumberan integer,stateandhtml_urlstrings. Violations raiseGitHubErrornaming the endpoint and the malformed field — never a rawTypeError/SyntaxError, never a silently coerced orundefinedvalue. - A malformed 2xx create-issue body does not trigger the
ghfallback create (the issue may already exist server-side); it surfaces as an explicit error. Malformed installation/token replies may still fall back togh(no side effect has happened yet), with the malformed-body reason preserved in the combined error. - New regression tests (new
test/github.test.tsor extendingtest/attach_verify.test.ts, stubbedfetchin the existing style) cover at least: installation{}, token{}, token numeric, create{}, create wrong-typed fields, lookup{}, and anullbody — each failing on the pre-fix code — while the well-formed control cases and the existing dispatch suite stay green. - No behavior change for well-formed responses or for definitive HTTP failures (404 lookup still returns
null; non-2xx still raises/falls back as today).
Dedup: searched open + closed issues for installationToken, "dispatch github shape", and pm-dispatch GitHub-client titles — no hits. #6954 covers pm-stack/projector/src/github.ts, not this client; #7085 covers pm-stack/dispatch/src/opencode.ts, not this module.
Activity
developing-today commentedon Nov 8, 2026
CODE-2250
dezren39 commentedon Nov 8, 2026
🤖 Agent note · filed
Merge pull request #8088 from developing-today/queue/12768-7101-githu…
dezren39 commentedon Nov 10, 2026
🤖 Agent note · done
pm-stack/dispatch/src/github.tsat the boundary; issue pm-dispatch(github): GitHub API response bodies are shape-trusted — a token-less access-token reply is sent as Bearer undefined, a wrong-shape create reply is returned as a successful issue, and a null create body falls back to a duplicate gh create #7101 closed by the PR.test/github.test.ts12/12 post-fix, 9 fail pre-fix; full dispatch suite 169/169. Codex review run failed on usage limits with no findings (disposition recorded on PR fix(pm-dispatch): validate GitHub API response shapes at the boundary (#7101) #8088).