Skip to content

fix: return 404 when updating or deleting a record that does not exist - #77

Draft
sonnymay wants to merge 2 commits into
mainfrom
claude/vibrant-meitner-dud36u
Draft

sonnymay wants to merge 2 commits into
mainfrom
claude/vibrant-meitner-dud36u

Conversation

@sonnymay

@sonnymay sonnymay commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Updating a nonexistent customer, device, ticket, or RMA, or deleting a nonexistent customer, previously returned HTTP 200 with []. The shared require_row helper now returns HTTP 404 with a resource-specific message when the database mutation matches no row. Successful responses remain unchanged.

Ticket updates check the mutation result before writing status history, including when a ticket disappears between the initial lookup and the update.

Related PRs and integration

This PR consolidates the missing-record behavior proposed in #45 (tickets) and #46 (customers, devices, and RMAs). Prefer this implementation as their replacement, retaining its post-mutation check for concurrent deletion. Those PRs remain open.

#75 adds UUID validation: malformed IDs should return 422, while valid UUIDs with no matching row return 404. The new missing-record tests use valid UUIDs.

Merge simulations against the reviewed branch tips found implementation conflicts with #45, #46, #73, #75, and #76; #72 conflicts only in test additions. #43 and #74 merge cleanly. When integrating #73/#75/#76, preserve their timestamp, UUID conversion, and optional-field normalization changes while keeping require_row around the final database result.

Validation

  • Full backend suite: 49 passed, using dummy SUPABASE_URL and SUPABASE_KEY values (no live Supabase connection).
  • Five parametrized missing-record cases assert HTTP 404, exact error details, execution of the mutation, and no history writes.
  • Added a regression test for a ticket found by the initial lookup but missing at update time: HTTP 404 and no history write.
  • ruff check ., ruff format --check ., and git diff --check passed.
  • The existing header test still depends on SUPABASE_URL being configured; test: make get_headers test independent of SUPABASE_URL env #43 fixes that independently. No real credentials are required for these tests.
  • The Vercel preview is a frontend deployment, not live validation of these backend routes.

…or RMA that does not exist

PATCH/DELETE against PostgREST matching no row returns [], which the API passed
through as a 200. Clients could not tell a missing record from a successful edit.

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

vercel Bot commented Nov 16, 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 21, 2026 7:36pm UTC

This branch was successfully deployed

1 active deployment
Preview — 7a5c87c8 Deployed Nov 21, 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