docs(catalogs): PATCH /api/catalogs/{catalogId} rename contract (chat#1942)

Merged
SW
4mo ago
+128-0

Row 2 of chat#1942. Contract-first: this is the spec the api implementation fulfills, and it merges before it.

What this documents

PATCH /api/catalogs/{catalogId} — rename a catalog. The only mutable field is name; membership stays with the catalog-songs endpoints.

  • Request: { "name": string } (required, non-empty) → new UpdateCatalogRequest schema.
  • 200: { "status": "success", "catalog": Catalog } → new UpdateCatalogResponse, reusing the existing Catalog schema.
  • 400 / 401 / 404 / 500, all on the existing CatalogsErrorResponse schema.

The one decision worth reviewing: 404, not 403

chat#1942 proposed "a non-member gets 403; an unknown id gets 404." This contract documents 404 for both, because that is what the sibling catalog reads already do — getCatalogMeasurementsHandler resolves visibility with getCatalogOwnerIds + selectAccountCatalog and returns 404 when no link is found, deliberately: "a catalog owned by nobody in accountIds returns null, indistinguishable from not existing" (selectAccountCatalog).

A 403 on a catalog you cannot see would confirm that catalog exists — an IDOR-shaped leak the catalog read paths were explicitly built to avoid. Splitting the semantics across verbs on the same resource would be worse than either choice alone, so rename follows the read paths. Flagged on the issue as a deviation from its acceptance criteria.

Files

  • api-reference/openapi/releases.json — new /api/catalogs/{catalogId} path + 2 schemas. Purely additive: 119 insertions, 0 deletions; re-parsed after the edit.
  • api-reference/songs/catalog-rename.mdx — reference page.
  • docs.json — nav entry under Catalogs, which is also what puts it in the generated llms.txt.

Merge order

docs (this) → api PATCH implementation. Both land after api#820 (the naming fix, which needs no contract change) per the issue's sequencing.

🤖 Generated with Claude Code


Summary by cubic

Documents the PATCH /api/catalogs/{catalogId} rename contract so existing catalogs can be given real names. Uses 404 for non-visible catalogs to match read paths and avoid leaking existence (aligns with chat#1942).

  • New Features

    • Add PATCH /api/catalogs/{catalogId} to OpenAPI: body { "name": string } (required, non-empty) via UpdateCatalogRequest.
    • 200 returns { "status": "success", "catalog": Catalog } via UpdateCatalogResponse; 400/401/404/500 reuse CatalogsErrorResponse.
    • Document 404 (not 403) when the catalog isn’t visible to the caller, consistent with read endpoints.
    • Add api-reference/songs/catalog-rename.mdx and a nav entry in docs.json. Purely additive to api-reference/openapi/releases.json.
  • Bug Fixes

    • Require status and catalog in UpdateCatalogResponse so clients don’t treat catalog as optional.
    • Keep the reference page frontmatter-only per docs policy.