Repository navigation
docs: explain shorebird api, pagination and error documentation_url - #726
Conversation
|
Adversarial review (separate agent): Tier 2, one docs file. Every claim checked against
Checked and accurate: the default method and when it switches to POST; |
|
Addressed in 1de9ef9:
|
…and as the example
AbhishekDoshi26
left a comment
There was a problem hiding this comment.
Reviewed at ff9526e.
Verdict: Changes requested. The facts on the page check out against source, but the agent entry points and one other page are out of step with it, and there are two small nits.
Checked
shorebird apibehavior in shorebirdpackages/shorebird_cli/lib/src/commands/api_command.dart(origin/main):- Only the response body goes to stdout (
runWithStdoutOnStderr). - A non-2xx response prints the raw body and exits 1 (
requestFailedExitCode). --jqis applied only whensucceeded.- Requests are authenticated with the login session or
SHOREBIRD_TOKEN. -X GETwith-fputs the fields in the query string.
- Only the response body goes to stdout (
- The command is not in v1.6.128 (
pubspec.yamlon main is still 1.6.128).shorebird metricsis also not in v1.6.128 (added in shorebird#4083). The "releases after 1.6.128" marker covers both. shorebird account orgsprints the orgidfirst (account/orgs_command.dart).shorebird apps listandshorebird releases listexist.- The jq subset in
jq.dartsupportsselectand!=.select(. != null)on a missingnext_cursorprints nothing, so the loop's[ -n "$cursor" ] || breakends it correctly. - Example
GET /organizations/{organizationId}/users:- The route exists (
routes/api/v1/organizations/[organizationId]/users/index.dart) and is not paged. - The response shape
users[].user.emailmatchesGetOrganizationUsersResponse,OrganizationUserandPublicUserinpublic/openapi.yaml.
- The route exists (
- Pagination in
lib/src/pagination.dart:per_pagedefaults to 30 and is clamped to 100.next_cursoris left out on the last page.- A bad cursor returns 400
invalid_cursor.
- Paged routes:
- Apps, releases and patches list everything unless
per_pageorcursoris sent (PageRequest.readwithoutpagedByDefault). - Invitations, audit logs and previews page by default.
/appsreturnsapps[].app_id(GetAppsResponse,AppMetadata).
- Apps, releases and patches list everything unless
ErrorResponsehascodeandmessage(required) plusdetailsanddocumentation_url(openapi.yaml). Theerror_documentation_url.dartmiddleware addsdocumentation_url.- The anchor
#common-patternsresolves to the## Common patternsheading. - No em-dashes in added lines. Prettier, cspell and vale are clean on
src/content/docs/account/api.mdx. - Existing review items (cursor loop, version wording,
--jqon errors) are addressed and not raised again.
Findings
-
Agent entry points not updated.
- Where:
public/.well-known/agent-instructions.txt:31,astro.config.mjs:228,public/.well-known/agent-skills/index.json:43. - Problem: The page now documents a new CLI command that is aimed at agents and scripts. None of the three hand-maintained agent entry points mention it. They still describe the API only as raw HTTP with a bearer token.
- Fix,
agent-instructions.txtitem 2: append "From a shell,shorebird api <endpoint>(Shorebird CLI releases after 1.6.128) calls any endpoint with yourshorebird loginsession orSHOREBIRD_TOKEN, prints only the response body, and exits 1 on a non-2xx response;--jqfilters successful responses. Guide: https://docs.shorebird.dev/account/api.md" - Fix,
astro.config.mjs"Code Push REST API" line in thedetails: append " From the CLI, 'shorebird api ' (releases after 1.6.128) sends authenticated requests without handling tokens (reference: https://docs.shorebird.dev/account/api.md)." - Fix,
index.json: change theshorebird-apidescription to "Programmatic access to Shorebird apps, releases, artifacts, and channels via REST OpenAPI 3.1, or from the CLI withshorebird api."
- Where:
-
shorebird apirejects--json, but another page says other commands accept it.- Where:
src/content/docs/code-push/ci/scripting.mdx:63-65, together withsrc/content/docs/account/api.mdx:35. - Problem:
scripting.mdxsays commands not in its table "accept--jsonand run non-interactively".shorebird apiis not in the table, and it does not accept--json:_runcallsusageException('shorebird api prints the response body as-is and does not support --json.')whenisJsonMode. An agent followingscripting.mdthat adds the global--jsongets a usage error. The new section does not mention this either. - Fix,
api.mdxline 35: change "Only the response body goes to stdout," to "Only the response body goes to stdout (the global--jsonflag is not supported),". - Fix,
scripting.mdxafter line 65: add "shorebird apiis the exception: it prints the API response body as-is and rejects--json. See Calling the API from the command line."
- Where:
-
Mixed punctuation in the Common patterns list.
- Where:
src/content/docs/account/api.mdx:133. - Problem: The PR changed the
**Errors**bullet from an em-dash to a colon and added**Pagination**:with a colon. The third bullet in the same list still follows**Unauthenticated endpoint**with an em-dash, so the list mixes styles and keeps an em-dash on a page this PR edits. - Fix:
- **Unauthenticated endpoint**:POST /patches/checkis the one exception to
- Where:
-
The pagination loop closes an interactive terminal on failure.
- Where:
src/content/docs/account/api.mdx:127-128. - Problem: The loop uses
|| exit 1. The intro calls it "This loop", which invites pasting it into a terminal. If a request fails there (for example, when not logged in),exit 1closes the user's terminal. - Fix: change the intro on line 119 to "This script prints every app ID, one page of 50 at a time, stops when a page has no
next_cursor, and exits with status 1 if a request fails:". Keep the code as is.
- Where:
AbhishekDoshi26
left a comment
There was a problem hiding this comment.
Reviewed at b4244e0.
Verdict: two findings left. The four findings from the previous review are fixed correctly, and every factual claim on the page matches source.
Checked
- Previous fixes: the agent entry points (
agent-instructions.txt, the llmsdetailsinastro.config.mjs, theshorebird-apientry inindex.json) now mentionshorebird apiwith wording that matches source.api.mdxandscripting.mdxsay--jsonis rejected, matching theusageExceptioninapi_command.dart. The**Unauthenticated endpoint**bullet uses a colon, and the loop intro says "This script". api_command.dart: the response goes throughrunWithStdoutOnStderr,requestFailedExitCodeis 1,--jqapplies only on success, and-X GETwith-fsends query parameters.jq.dart: a missing key yields null, andselectdrops it, so.next_cursor | select(. != null)prints nothing on the last page and the loop ends..apps[].app_idmatchesAppMetadatainpublic/openapi.yaml._shorebirdpagination.dart:per_pagedefaults to 30 and is clamped to 100, andnext_cursoris left out on the last page. Apps, releases and patches return everything withoutper_pageorcursor. Invitations, audit logs, previews and preview notes page by default.GET /organizations/{organizationId}/usersis readable by every role down to viewer (permission.dart), andusers[].user.emailmatches the response.- Anchors resolve, there are no em-dashes, and Prettier, vale and cspell are clean on the changed text.
Findings
src/content/docs/account/api.mdx:30-31:shorebird metricsis not in a released CLI. The section lists it among the everyday commands, but it was added in shorebird#4083 after v1.6.128, and the page's version note covers onlyshorebird api. Fix: "For everyday tasks, use the dedicated commands (shorebird apps list,shorebird releases list,shorebird patches list, and so on)."- The PR description no longer matches the diff. It says "two minimal examples" (there is one), Testing mentions
{appId}examples that no longer exist, and "What changed" omits thescripting.mdxnote and the agent entry point updates. Fix: update those three places.
AbhishekDoshi26
left a comment
There was a problem hiding this comment.
Reviewed at df27327.
Verdict: clean, no findings at any severity. Both earlier rounds' findings are fixed, the description matches the diff, and every factual claim matches source.
Checked
- Earlier findings:
shorebird metricsis gone from the everyday-commands list. The description now covers one example, thescripting.mdxnote and the agent entry points. The round 1 fixes are still in place. api_command.dart(shorebird main): only the body goes to stdout (runWithStdoutOnStderr),--jsonraises ausageException, a non-2xx response prints the raw body and exits 1,--jqruns only on success, credentials come from theshorebird loginsession orSHOREBIRD_TOKEN, and-X GETwith-fsends query parameters.shorebird account orgs,apps list,releases listandpatches listall exist in v1.6.128.jq.dart:selectand!=are supported, so the pagination loop ends on the last page.pagination.dart(_shorebird):per_pagedefaults to 30 and is clamped to 100,next_cursoris left out on the last page, and a bad cursor returns 400invalid_cursor. Apps, releases and patches return everything unless a page is requested. Invitations, audit logs, previews and preview notes page by default.- The example endpoint
/organizations/{organizationId}/usersis a GET gated on.view(.organizationMembers), andusers[].user.emailmatches the response types. error_documentation_url.dartaddsdocumentation_urlto every JSON 4xx/5xx body with acode.- The agent entry points are accurate,
index.jsonparses, the anchors resolve, there are no em-dashes, and Prettier, cspell and vale are clean on the changed text.
Findings
None.
The CLI now has
shorebird api, an authenticated passthrough to the Shorebird API meant mainly for coding agents and scripts, but the API reference page (which every API error'sdocumentation_urlnow links to) only described raw HTTP with a bearer token. This adds a "Calling the API from the command line" section toaccount/api.mdx, and updates the page's common patterns for the error body'sdocumentation_urland the new cursor pagination.What changed
src/content/docs/account/api.mdx:shorebird api: what it is for (mainly agents and scripts; only the body on stdout; non-zero exit on failure;--jqapplies only to successful responses), discovery via the OpenAPI spec, one example (listing an organization's members), and a pointer toshorebird api --helpfor all options. The CLI documents its own flags, so the page doesn't repeat them.documentation_urland says to branch oncode.per_page(default 30, max 100),cursorandnext_cursoron the apps, releases and patches lists, with a loop that walks every page and stops whennext_cursoris absent. Notes that some newer list endpoints page by default.src/content/docs/code-push/ci/scripting.mdx: notes thatshorebird apirejects--json.Agent entry points (
agent-instructions.txt, the llms.txtdetailsinastro.config.mjs,agent-skills/index.json): mentionshorebird api.Release timing
shorebird apishipped in Shorebird 1.6.129, and the page says it needs 1.6.129 or newer. Ready to land.Testing
packages/shorebird_cli/lib/src/commands/api_command.darton shorebird main./apps(80 apps),/apps?per_page=2(2 apps plusnext_cursor), followingnext_cursorwith-X GET -f per_page=2 -f cursor=...(next 2 apps), andcursor=garbage(400invalid_cursorwithdocumentation_url, exit 1).npm run build(astro check and build): passes, 68 pages.lint-component-labels: clean. Vale was not run (not installed locally).