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

A repository's branches and tags answer `{ items, next_cursor }` #5055

Parked opened this
Closed without merging

GET /api/v1/repos/:owner/:name/branches and …/tags now answer { items, nextcursor } instead of a bare array. This is a breaking change to the response shape for any client of those two routes. Paging: limit defaults to 50 and takes whole numbers from 1 to 200.

Notes

stopped parked by the crew deploy 86afb94

opened this

GET /api/v1/repos/:owner/:name/branches and …/tags now answer { items, next_cursor } instead of a bare array. This is a breaking change to the response shape for any client of those two routes.

  • Paging: limit defaults to 50 and takes whole numbers from 1 to 200. A bad limit is a 422 invalid_limit. cursor is the previous page's next_cursor, which is the last ref's name. A cursor that matches no ref is a 422 invalid_cursor. next_cursor is null on the last page.
  • Unchanged: order (tags newest first), permissions and the item fields. A repository whose refs can't be listed still answers an empty page.
  • Implementation: one helper, refPage, in src/http/api.ts serves both routes.
  • Tests: the new test/ref-pages.test.ts covers the shape, paging to the end, and refused limits and cursors. I updated the existing tests that read the array. Type check and the nine suites that touch these routes pass (75 tests); I did not run the full check.
  • Callers: nothing else in src/ reads these two routes, so no source changes were needed there. That covers the terminal UI, client.ts, mcp.ts and the pages, which read refs straight from git.
  • Left out: the origin-browse routes (…/browse/branches and …/browse/tags) still answer bare arrays, because the issue didn't name them and other issues are changing lists in parallel.
  • Cursor choice: the cursor is the ref name, so if that ref is deleted between pages the next request is a 422. I took that over an offset cursor, which would silently skip or repeat refs.

To try it: curl "$FORGE_URL/api/v1/repos/OWNER/NAME/tags?limit=2", then pass the returned next_cursor as cursor=.

Closes #5041

commented

GET /api/v1/repos/:owner/:name/branches and …/tags now answer { items, next_cursor } instead of a bare array. This is a breaking change to the response shape for any client of those two routes.

  • Paging: limit defaults to 50 and takes whole numbers from 1 to 200. A bad limit is a 422 invalid_limit. cursor is the previous page's next_cursor, which is the last ref's name. A cursor that matches no ref is a 422 invalid_cursor. next_cursor is null on the last page.
  • Unchanged: order (tags newest first), permissions and the item fields. A repository whose refs can't be listed still answers an empty page.
  • Implementation: one helper, refPage, in src/http/api.ts serves both routes.
  • Tests: the new test/ref-pages.test.ts covers the shape, paging to the end, and refused limits and cursors. I updated the existing tests that read the array. Type check and the nine suites that touch these routes pass (75 tests); I did not run the full check.
  • Callers: nothing else in src/ reads these two routes, so no source changes were needed there. That covers the terminal UI, client.ts, mcp.ts and the pages, which read refs straight from git.
  • Left out: the origin-browse routes (…/browse/branches and …/browse/tags) still answer bare arrays, because the issue didn't name them and other issues are changing lists in parallel.
  • Cursor choice: the cursor is the ref name, so if that ref is deleted between pages the next request is a 422. I took that over an offset cursor, which would silently skip or repeat refs.

To try it: curl "$FORGE_URL/api/v1/repos/OWNER/NAME/tags?limit=2", then pass the returned next_cursor as cursor=.

commented

Parked by the crew: the check failed ("origins: connecting, mirroring, writing through > mirroring creates the repo, fetches git, and imports the units") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs