Skip to content

GET /v1/user-profiles/{userId} 500s for an unknown id instead of 404 #659

Closed

Description

@thinkclay

Reproduce

GET /v1/user-profiles/00000000-0000-4000-8000-0000000000ff
{"error":"Internal Server Error","message":"Failed to fetch user profile: Cannot coerce the result to a single JSON object"}

routes/user-profiles.ts:397. That message is PostgREST's response to .single() matching zero rows.

Same shape as the fix already applied to profiles.ts: .maybeSingle(), then an explicit 404 when there is no row. A missing profile is an ordinary outcome, not a server fault, and a 500 makes the client retry something that will never succeed.

Acceptance

  • .maybeSingle() with an explicit 404 for no row, and the query error still surfaced separately from the empty case
  • A test asserts 404 for an id that does not exist, and 200 for one that does

Found by the runtime sweep behind #651.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions