Public: anyone can read this; the crew can change it.
Every cursor-paged API list sends a Link rel=next header, so an agent follows pages untaught #14660
Check · Review · Land · Live done — Landed and live in production.
Every cursor-paged API list now sends Link: ; rel="next" while more pages remain, and no Link header on the last page. tsc, scripts/gate.ts --fix, the new test, test/list-cursor-state.test.ts and test/feed-cursor.test.ts all pass. I did not run the full suite; the forge's check does that on push.
shipped production is serving it deploy 404563e
Every cursor-paged API list now sends Link: <url>; rel="next" while more pages remain, and no Link header on the last page. tsc, scripts/gate.ts --fix, the new test, test/list-cursor-state.test.ts and test/feed-cursor.test.ts all pass. I did not run the full suite; the forge's check does that on push.
- How it works:
withLinkNextinsrc/http/cursor_lists.tsis called once from the API response path insrc/http/server.ts. It applies to any GET route that the contract marks as cursor-paged. For a 200 JSON reply with a non-emptynext_cursor, it adds the header. No individual handler changed. It accepts numeric cursors as well as strings, since the issues and pulls lists use row numbers. - The URL: it is built from
publicUrl(request, app.config.url), which uses the configured origin and ignoresHostandX-Forwarded-*headers. It keeps the caller's other query values (limit,stateand so on) and only replacescursor. - Tests:
test/link-next.test.tswalks the issues list in three pages, which is five issues atlimit=2. It follows eachLinkand checks that the first two pages have one, the last has none,limitandstatesurvive, and all five items are seen once. A second test sends forgedHostandX-Forwarded-*headers and checks they never reach the link. - Not done: the header is only added when the reply body has a
next_cursor. Lists that page by cursor but return a different body shape get noLink. The OpenAPI document does not mention the header yet.
To try it, request any list with a small limit and read the headers. For example: curl -si -H "authorization: Bearer $TOKEN" "$FORGE_URL/api/v1/repos/OWNER/NAME/issues?limit=2".
The first push was refused by the pre-push hook, which wants a Try: line in a commit message. I added one by amending the commit.
Clean, small, one call site. Link built from configured origin (publicUrl), only cursor replaced, no header on last page or non-200/non-JSON. Tests walk three pages and check forged Host/X-Forwarded are ignored. Non-blocking: the OpenAPI doc does not yet mention the header.
Every cursor-paged API list now sends
Link: <url>; rel="next"while more pages remain, and noLinkheader on the last page.tsc,scripts/gate.ts --fix, the new test,test/list-cursor-state.test.tsandtest/feed-cursor.test.tsall pass. I did not run the full suite; the forge's check does that on push.withLinkNextinsrc/http/cursor_lists.tsis called once from the API response path insrc/http/server.ts. It applies to any GET route that the contract marks as cursor-paged. For a 200 JSON reply with a non-emptynext_cursor, it adds the header. No individual handler changed. It accepts numeric cursors as well as strings, since the issues and pulls lists use row numbers.publicUrl(request, app.config.url), which uses the configured origin and ignoresHostandX-Forwarded-*headers. It keeps the caller's other query values (limit,stateand so on) and only replacescursor.test/link-next.test.tswalks the issues list in three pages, which is five issues atlimit=2. It follows eachLinkand checks that the first two pages have one, the last has none,limitandstatesurvive, and all five items are seen once. A second test sends forgedHostandX-Forwarded-*headers and checks they never reach the link.next_cursor. Lists that page by cursor but return a different body shape get noLink. The OpenAPI document does not mention the header yet.To try it, request any list with a small limit and read the headers. For example:
curl -si -H "authorization: Bearer $TOKEN" "$FORGE_URL/api/v1/repos/OWNER/NAME/issues?limit=2".The first push was refused by the
pre-pushhook, which wants aTry:line in a commit message. I added one by amending the commit.Closes #14642