Skip to content

fix: reject malformed id path params with 422 instead of a retryable 503 - #75

Draft
sonnymay wants to merge 1 commit into
mainfrom
claude/vibrant-meitner-im4gqo
Draft

sonnymay wants to merge 1 commit into
mainfrom
claude/vibrant-meitner-im4gqo

Conversation

@sonnymay

Copy link
Copy Markdown
Owner

Summary

The {id} path parameters on /customers, /devices, /tickets (including /notes and /history) and /rmas were typed as str, so a non-UUID value from a stale link, a typo or crafted input went straight to Supabase. Postgres rejects that value for a uuid column with a 400. handle_response then turns the 400 into a 503 "temporarily unavailable" with Retry-After: 30, so clients are told to retry a request that can never succeed. For example, GET /tickets/abc returned a 503 instead of a client error.

These params are now typed as UUID, so FastAPI returns 422 before any DB call. As a side effect, crafted ids no longer reach a PostgREST filter at all. Escaping from #19 is kept as defence in depth. The frontend only sends DB-issued UUIDs, so its behaviour doesn't change.

No open PR (#17–#74) or issue covers malformed ids. Related but distinct:

Testing

  • Test fixtures now use real UUIDs instead of t1/c1 etc.
  • The id-escaping tests were replaced with a parametrized test: 8 routes × 3 malformed ids return 422, and the test fails if any DB helper is called.
  • pytest: 63 passed (with SUPABASE_URL/SUPABASE_KEY set). ruff check and ruff format --check are clean.

Generated by Claude Code

Path ids for customers, devices, tickets, notes, history and RMAs were
typed as plain strings, so a non-UUID value (stale link, typo, crafted
input) was sent straight to Supabase. Postgres rejects it for a uuid
column with a 400, which handle_response turns into a 503 "temporarily
unavailable" with Retry-After: 30 - telling clients to retry a request
that can never succeed.

Typing these params as UUID makes FastAPI return 422 before any DB call,
which also means crafted ids never reach a PostgREST filter. Tests now
use real UUID fixtures, and the id-escaping tests assert the 422.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0171zWzo22EqdMY1jm7ohaqw
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
supportops Ready Ready Preview Nov 14, 2026 3:03pm UTC

This branch was successfully deployed

1 active deployment
Preview — ecd903ac Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant