Public: anyone can read this; the crew can change it.

The api-* test files read no answer that disagrees with openapi.json #17990

opened this

Merged 15h 19m ago, live in production

I ran all 91 test/api-.test.ts files in two halves. They printed 13 CONTRACT lines before this change (5 + 8) and 0 after, with 186 + 143 tests passing.

Notes

opened this

I ran all 91 test/api-*.test.ts files in two halves. They printed 13 CONTRACT lines before this change (5 + 8) and 0 after, with 186 + 143 tests passing.

What changed

  • /api/v1/search (src/contract/openapi/routes/getApiV1Search.ts): the docs and note fields had a description written where their type belongs ("array of { title, path, snippet }…", "string, only when q is blank…"). No real value could match a type like that. They now say "array" and "string", and the description moved to the route's detail.
  • /api/v1/telemetry/home (getApiV1TelemetryHome.ts): live, main and behind were declared as objects, but the route sends null for them until the forge has stamped its build and read its own main branch. They are now declared "object|null". The route's own detail already said this.
  • ?fields= on /repos/{o}/{r}/pulls: this answer keeps only the keys it names, while PullItem lists every key as required. I didn't relax PullItem to fit, because then generated clients couldn't count on any key being there. Instead it's a new line under "Known bends" in docs/features/api-shape-changes.md, and test/helpers/contract-fetch.ts no longer reports item keys missing from a fields= answer. It still checks the types of the keys that are kept.
  • docs/features/api-shape-changes.md also gets a line under "Changes clients follow" for the two route declarations. What the routes send did not change.

Tests: test/support/conforms.test.ts gains two tests:

  • One checks the two corrected route declarations; it fails without the route changes.
  • One checks the fields= rule: a trimmed answer passes, a kept key of the wrong type still fails, and a full list still fails on a missing key.

Nothing else is new: the fixes use the existing declared, disagreements and reply type strings.

Checks: bun x tsc --noEmit and bun scripts/gate.ts --explain (32 of 32 rules) pass. scripts/fast.ts said the change touches too much to name the tests, because the shared test preload reaches every file. So I picked 108 files covering openapi, contract, search, telemetry, features, swift, dead code and module-level state: 1119 pass, 0 fail.

Left for the next part: outside the api-* files, GET /api/v1/repos/issues/search prints $: is array, declared object twice. I haven't checked which route that answer is being matched to.

To try it: bun test test/support/conforms.test.ts, then bun test $(ls test/api-*.test.ts | head -50) and the rest; neither prints a CONTRACT line.

🤖 Generated with Claude Code

Closes #17986

commented

I ran all 91 test/api-*.test.ts files in two halves. They printed 13 CONTRACT lines before this change (5 + 8) and 0 after, with 186 + 143 tests passing.

What changed

  • /api/v1/search (src/contract/openapi/routes/getApiV1Search.ts): the docs and note fields had a description written where their type belongs ("array of { title, path, snippet }…", "string, only when q is blank…"). No real value could match a type like that. They now say "array" and "string", and the description moved to the route's detail.
  • /api/v1/telemetry/home (getApiV1TelemetryHome.ts): live, main and behind were declared as objects, but the route sends null for them until the forge has stamped its build and read its own main branch. They are now declared "object|null". The route's own detail already said this.
  • ?fields= on /repos/{o}/{r}/pulls: this answer keeps only the keys it names, while PullItem lists every key as required. I didn't relax PullItem to fit, because then generated clients couldn't count on any key being there. Instead it's a new line under "Known bends" in docs/features/api-shape-changes.md, and test/helpers/contract-fetch.ts no longer reports item keys missing from a fields= answer. It still checks the types of the keys that are kept.
  • docs/features/api-shape-changes.md also gets a line under "Changes clients follow" for the two route declarations. What the routes send did not change.

Tests: test/support/conforms.test.ts gains two tests:

  • One checks the two corrected route declarations; it fails without the route changes.
  • One checks the fields= rule: a trimmed answer passes, a kept key of the wrong type still fails, and a full list still fails on a missing key.

Nothing else is new: the fixes use the existing declared, disagreements and reply type strings.

Checks: bun x tsc --noEmit and bun scripts/gate.ts --explain (32 of 32 rules) pass. scripts/fast.ts said the change touches too much to name the tests, because the shared test preload reaches every file. So I picked 108 files covering openapi, contract, search, telemetry, features, swift, dead code and module-level state: 1119 pass, 0 fail.

Left for the next part: outside the api-* files, GET /api/v1/repos/issues/search prints $: is array, declared object twice. I haven't checked which route that answer is being matched to.

To try it: bun test test/support/conforms.test.ts, then bun test $(ls test/api-*.test.ts | head -50) and the rest; neither prints a CONTRACT line.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs