Public: anyone can read this; the crew can change it.
Every /api/v1 answer the suite reads is checked against openapi.json, not onl… #17961
Picked up by mason; no pull came of it (failed) · 10+ runs · run
4 earlier comments · 2 events
For the test, a stub is simpler than a real forge: Bun.serve({ port: 0, fetch: () => Response.json({ ...a valid PullDetail sample..., approvedAt: { at: "x" } }) }), then await expect(fetch(\${url}/api/v1/repos/a/b/pulls/1\)).rejects.toThrow("$.approvedAt: is object, declared string|null"). A valid sample answer must pass through untouched in the same test, so the wrapper is shown not to fire on a conforming answer.
The collecting run of the full suite is still going in the background, so step 3's throw is not on yet. Nothing is committed or pushed.
What exists in the clone:
- Wrapper:
test/helpers/contract-fetch.tswrapsfetch, and the preload loads it only underbun test. WithFORGE_CONTRACT_COLLECTset it prints disagreements asCONTRACT …lines instead of throwing. - Tests:
test/support/conforms.test.tshas two new cases. One expects the wrapped fetch to reject with$.approvedAt: is object, declared string|null. The other shows a conforming sample, an undeclared route and a non-API path passing untouched. The file passes (3 tests). - Doc: the sentence in
docs/features/api-shape-changes.mdis reworded to say every API answer a test reads is checked.
Still to do once the suite finishes:
- Fix each listed disagreement in
src/contract/openapi/schemas/*, declaring the type the route already serves. - Add any bends found to "Known bends".
- Turn the throw on by dropping the
FORGE_CONTRACT_COLLECTbranch. - Run
bun scripts/gate.ts --explainand--fix,bun x tsc --noEmitand the suites that cover the change, then commit and push.
Parked by the crew: the run ended without a pull: no changes pushed (timeout)
Parked twice since a person last spoke here, so it is the planner's now. Every reason:
- the run ended without a pull: no changes pushed: The collecting run of the full suite is still going in the background, so step 3's throw is not on yet. Nothing is committed or pushed
- the run ended without a pull: no changes pushed (timeout)
The planner splits it, replaces it with a fresh issue, or defers it; a person can also say what to try. Nothing starts here until then, and the board lists it.
Split: both runs stalled waiting on one background full-suite collecting run. Now four pieces, none needing a full-suite run: #17985 the wrapper in collect mode with its test, #17986 schema fixes for test/api-*, #17987 schema fixes for the other files that read /api/v1, #17988 turn the throw on and update the doc. scout's clone notes above describe #17985 almost exactly.
Every /api/v1 answer the suite reads is checked against openapi.json, not only the pull detail
#17944 asked for a contract test "run over the route samples the tests already produce". #17945 added the checker (test/support/conforms.ts) and calls it from one test, test/approval-base.test.ts, so a silent type change on any other route (issues, comments, lists, /user/repos) still ships green and breaks the iOS app the same way approvedAt did.
Change, in the suite's existing preload (test/helpers/preload.ts, which bunfig.toml loads for every bun test):
openapi("https://forge.test", "test", "admin")(src/contract/openapi.ts), and from itspathsa list of { method, regex, literals } where each{param}becomes[^/]+, anchored^…$, andliteralscounts the segments without a param.disagreements(await res.clone().json(), schema, doc). Skip silently when no route matches or none is declared.Error(\GET ${pathname} disagrees with openapi.json (#17944): ${list.join("; ")}\)so the test that read it goes red, naming the field.Before turning step 3 on: run the full suite once with step 3 only collecting, and fix every disagreement it lists in the schema (src/contract/openapi/schemas/*), declaring the type the route already serves, since that is what clients decode today. Never change a served type to satisfy the schema. Add any bend found to "Known bends" in docs/features/api-shape-changes.md. Then turn the throw on, and change that page's sentence "A route's tests add the same check as they gain samples" to say every API answer a test reads is checked.
Test: test/support/conforms.test.ts gains a case that starts a forgeHttp server whose GET /api/v1/repos/{o}/{n}/pulls/{n} answer has approvedAt as an object, and expects the wrapped fetch to reject with "$.approvedAt: is object, declared string|null". It fails without the preload change. The explicit check in approval-base.test.ts can stay.
No change to production code or to any served shape.