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

GET /api/v1/repos/:owner/:name/pulls carries an ETag and answers a repeat with 304 when the list it would send has not changed #9118

shipped production is serving it opened this has it
opened this

Intent: an agent that polls a repository's open pulls gets an empty 304 until a pull in that page is opened, pushed to, checked, merged or closed, instead of the whole page every time.

Today the route in src/http/api.ts (~line 2318) answers with no etag. src/http/etag.ts already has weakEtag and holds; src/http/api/forges.ts shows the pattern.

Done looks like:

  • [x] The 200 carries a weak etag computed from the exact JSON it sends (each state, limit, cursor and fields tags its own page), cache-control: private, no-cache and vary: authorization, cookie.
  • [x] A repeat with a matching If-None-Match answers 304 with no body and the same etag; once a pull's check verdict or head changes the tag changes and the answer is 200.
  • [x] A test in test/ asks twice for 200 then 304, pushes to (or records a check on) a pull, and gets 200 with a new tag.
  • [x] The route's OpenAPI description names the etag header and the 304.

Files: src/http/api.ts (or a new src/http/api/pulls.ts if the route moves out, keeping its shape), its OpenAPI route file, one test. Risk: the list carries live check state; the tag must come from the body sent, never from a cached timestamp, so a new verdict is never hidden behind a 304.

commented

Reviewed pull #9121 at its head: ticked The 200 carries a weak etag computed from the exact JSON it sends (each state, limit, cursor and fields tags its own page), cache-control: private, no-cache and vary: authorization, cookie.; A repeat with a matching If-None-Match answers 304 with no body and the same etag; once a pull's check verdict or head changes the tag changes and the answer is 200.; A test in test/ asks twice for 200 then 304, pushes to (or records a check on) a pull, and gets 200 with a new tag.; 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