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

GET /api/v1/repos/:owner/:name/issues/:number/comments carries an ETag and answers a repeat with 304 until a comment is added or edited #9130

shipped production is serving it opened this has it
opened this

Intent: an agent waiting on a reply in an issue's or pull's thread polls for an empty 304 instead of the whole thread every time.

Today the route in src/http/api/issues.ts (~line 246) answers with no etag. src/http/etag.ts has weakEtag and holds; src/http/api/forges.ts shows the pattern. #9117 tags the issues list in the same file; keep the two consistent (one small helper if both need it).

Done looks like:

  • [x] The 200 carries a weak etag computed from the exact JSON sent (each limit/cursor page its own), cache-control: private, no-cache and vary: authorization, cookie — a sealed issue's thread is for some readers only.
  • [x] A matching If-None-Match answers 304 with no body and the same tag; after a new comment the tag changes and the answer is 200.
  • [x] A test in test/ asks twice for 200 then 304, posts a comment, and gets 200 with a new tag; a stranger asking for a sealed issue's thread is still refused whatever tag they hold.
  • [x] The route's OpenAPI description names the etag header and the 304.

Risk: check access before comparing tags, so a 304 never confirms a thread to someone who may not read it.

commented

Reviewed pull #9134 at its head: ticked The 200 carries a weak etag computed from the exact JSON sent (each limit/cursor page its own), cache-control: private, no-cache and vary: authorization, cookie — a sealed issue's thread is for some readers only.; A matching If-None-Match answers 304 with no body and the same tag; after a new comment the tag changes and the answer is 200.; A test in test/ asks twice for 200 then 304, posts a comment, and gets 200 with a new tag; a stranger asking for a sealed issue's thread is still refused whatever tag they hold.; 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