Title: 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 · Issue #7101 · developing-today/code · GitHub
Open Graph Title: 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 · Issue #7101 · developing-today/code
X Title: 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 · Issue #7101 · developing-today/code
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 Type...
Open Graph 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 GitH...
X 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 GitH...
Opengraph URL: https://github.com/developing-today/code/issues/7101
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"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","articleBody":"## Problem\n\n`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:\n\n- `github.ts:104-105` — the installation lookup: `const data = (await res.json()) as { id: number }; installationId = data.id;`\n- `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.\n- `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 };`\n- `github.ts:230-241` — issue lookup (`getIssue`): the same cast for `{ number, state, html_url, pull_request? }`.\n\nThis 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.\n\n## Evidence (verified this run)\n\nProbe 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.\n\nWith a wrong-shape 2xx, the client does **not** raise a boundary error:\n\n1. **Installation `{}`** → the token mint is POSTed to `/app/installations/undefined/access_tokens` (the undefined id used verbatim) and the flow \"succeeds\".\n2. **Access-token `{}`** → issue creation proceeds with the header `Authorization: Bearer undefined` and is reported as success (the probe stub records `authIsUndefined: true` on the create call). A numeric token (`{ token: 123, … }`) is likewise coerced and sent as `Bearer 123`. A bad `expires_at` is cached as `expiresAt: NaN`.\n3. **Create-issue `{}`** → `createIssue` returns `{}` — i.e. `{ number: undefined, url: undefined }` — **as a success**. Downstream (`src/server.ts`) that phantom ref feeds `canonicalDedupeKey(kind, repo, issue.number)`, the agent-note `comment(repo, issue.number, …)` and `addLabels(repo, issue.number, …)` calls, and the 201 response's `issue_number` — all against an issue that was never identified.\n4. **Create-issue `{ number: \"abc\", html_url: 42 }`** → returned verbatim as `{ number: \"abc\", url: 42 }`.\n5. **Lookup `{}`** → `getIssue` returns a non-null info with `number`/`state`/`url` all `undefined` (only `isPullRequest: false` survives serialization). The #3007 attach verification then rejects the target with `issue #\u003cn> … is undefined, not open` — a live, open issue refused on a fabricated state.\n6. **JSON `null` bodies** (installation, token, create, lookup) → a raw `TypeError` (`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 via `gh`.\n\n## Why it matters\n\npm-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.\n\n## Acceptance criteria\n\n- [ ] Every `res.json()` body in `pm-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; `id` a positive integer; `token` a non-empty string with a parseable `expires_at`; create/lookup `number` an integer, `state` and `html_url` strings. Violations raise `GitHubError` naming the endpoint and the malformed field — never a raw `TypeError`/`SyntaxError`, never a silently coerced or `undefined` value.\n- [ ] A malformed **2xx create-issue** body does not trigger the `gh` fallback create (the issue may already exist server-side); it surfaces as an explicit error. Malformed installation/token replies may still fall back to `gh` (no side effect has happened yet), with the malformed-body reason preserved in the combined error.\n- [ ] New regression tests (new `test/github.test.ts` or extending `test/attach_verify.test.ts`, stubbed `fetch` in the existing style) cover at least: installation `{}`, token `{}`, token numeric, create `{}`, create wrong-typed fields, lookup `{}`, and a `null` body — each failing on the pre-fix code — while the well-formed control cases and the existing dispatch suite stay green.\n- [ ] 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).\n\nDedup: 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.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-08T04:16:27Z","url":"https://github.com/developing-today/code/issues/7101"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:21d69158-5fd6-4f01-8482-62f5fb3a376b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB26:80C99:B299C0:ECD56A:6B063FA0 |
| html-safe-nonce | 84902d084e639faef64eee2c8cd4cac5b0003d6d999770a771f31b28bb4ad225 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjI2OjgwQzk5OkIyOTlDMDpFQ0Q1NkE6NkIwNjNGQTAiLCJ2aXNpdG9yX2lkIjoiODY5OTM2ODY1NTM5NTYzNTEwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7626ae1a4d3980be0d25265f192ebdaa9b9184e2788903415f432d8074702f98 |
| hovercard-subject-tag | issue:6267504986 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/7101/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c02be91fdb536fb6ac820a46bf93fa217c2a695b309824e717d141be7a2fe89d/developing-today/code/issues/7101 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c02be91fdb536fb6ac820a46bf93fa217c2a695b309824e717d141be7a2fe89d/developing-today/code/issues/7101 |
| og:image:alt | 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 GitH... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ac613d3698d3d8565651455086e1f74da07bf277 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width