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

GET /api/v1/repos/:owner/:name/pulls/:number carries an ETag and answers a repeat with 304 until the pull's head, checks, review or state change #9142

shipped production is serving it opened this has it
opened this

Intent: an agent waiting on one pull (its check verdict, a review, the merge) polls for an empty 304 instead of the whole pull every few seconds. The list (#9121), an issue's comments (#9134) and builds (#9132) already do this; the one pull does not.

Today the route in src/http/api.ts (~line 2473) answers with no etag. Follow the helper the lists use (weakEtag/holds in src/http/etag.ts, as in src/http/api/issues.ts).

Done looks like:

  • [x] The 200 carries a weak etag computed from the exact JSON sent, cache-control: private, no-cache and vary: authorization, cookie.
  • [x] A matching If-None-Match answers 304 with no body and the same tag; a new push, a recorded check verdict, a review and a merge each change the tag and the answer is 200.
  • [x] Access is checked before tags are compared: a stranger asking for a private repository's pull is a 404 whatever tag they hold.
  • [x] A test in test/ covers 200 then 304, then a new check verdict giving 200 with a new tag, and the stranger's 404.
  • [x] The route's OpenAPI description names the etag header and the 304.

Files: src/http/api.ts, its OpenAPI route file, one test. Risk: the pull carries live check state; the tag must come from the body sent, never a cached time, so a verdict is never hidden behind a 304.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

Reviewed pull #9146 at its head: ticked The 200 carries a weak etag computed from the exact JSON sent, cache-control: private, no-cache and vary: authorization, cookie.; A matching If-None-Match answers 304 with no body and the same tag; a new push, a recorded check verdict, a review and a merge each change the tag and the answer is 200.; Access is checked before tags are compared: a stranger asking for a private repository's pull is a 404 whatever tag they hold.; A test in test/ covers 200 then 304, then a new check verdict giving 200 with a new tag, and the stranger's 404.; The route's OpenAPI description names the etag header and the 304..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs