Skip to content

Align ErrNoManagedSource status code on GET/PUT /v1/entries/{type}/{name}/claims #771

@rdimitrov

Description

@rdimitrov

Context

Review feedback on #762 (comment) flagged that returning 503 Service Unavailable for service.ErrNoManagedSource is the wrong status code — it's an operator misconfiguration, not a transient backend outage. #762 reverted that change for POST /v1/entries (publishEntry) and DELETE /v1/entries/{type}/{name}/versions/{version} (deletePublishedEntry) back to 500 Internal Server Error, matching the rule in .claude/rules/data-model.md §3.

Two endpoints still return 503 for the same underlying error and are out of step with the rule:

Same reviewer logic applies to both.

Proposal

Pick one consistent status code for ErrNoManagedSource across all entry-claims endpoints (POST /v1/entries, DELETE /v1/entries/.../versions/..., PUT /v1/entries/.../claims, GET /v1/entries/.../claims).

Two reasonable options:

  1. Standardize on 500 — matches data-model.md §3 today, minimal churn (only the two claims endpoints change). Defensible as "no managed source = server misconfiguration, generic server error."
  2. Adopt a 4xx that better signals operator error — e.g. 409 Conflict or 412 Precondition Failed. More semantically accurate, but requires updating the rule, all four endpoints, their handler tests, and the Swagger annotations.

Pick one in the issue discussion and update:

  • internal/api/v1/entries.go (handler bodies + @Failure annotations)
  • internal/api/v1/entries_test.go (wantStatus cases)
  • docs/thv-registry-api/{docs.go,swagger.json,swagger.yaml} via task docs
  • .claude/rules/data-model.md §3 if option 2

Why now

Out of scope for #762 (review only flagged the two endpoints that PR modified) and out of scope for #761 (additive — same status as preceding endpoints). Tracking here so the inconsistency doesn't ship long-term.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions