fix(archive): guard non-uuid route params before querying — stray paths threw 22P02 in Postgres#673
Merged
Merged
Conversation
…hs threw 22P02 in Postgres
getWheel/getColor passed the raw catch-all segment into eq('id', ...) on a
uuid column, so hits like /archive/colors/review (and the 'noWheel' fallback)
logged "invalid input syntax for type uuid" errors in Postgres. Validate the
param against the repo's UUID_RE idiom and return null (existing not-found
path) before any query. Adds regression tests asserting Supabase is never
called for non-uuid ids.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR prevents noisy Postgres 22P02 invalid input syntax for type uuid errors from /archive/wheels/* and /archive/colors/* by short-circuiting getWheel/getColor when the route param is not a UUID, avoiding unnecessary Supabase/Postgres queries while keeping the same “not found” UX.
Changes:
- Added a
UUID_REguard ingetWheelandgetColorto returnnullbefore querying when the id is not UUID-shaped. - Updated unit tests to call
getWheel/getColorwith UUID-like inputs and added regression tests asserting invalid ids do not call Supabase.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/composables/useWheels.ts | Adds UUID validation guard to prevent invalid route params from reaching eq('id', ...) on a uuid column. |
| app/composables/useColors.ts | Adds UUID validation guard to prevent invalid route params from reaching eq('id', ...) on a uuid column. |
| tests/unit/composables/useWheels.test.ts | Updates call args to UUIDs and adds regression coverage that non-UUID ids return null without querying Supabase. |
| tests/unit/composables/useColors.test.ts | Updates call args to UUIDs and adds regression coverage that non-UUID ids return null without querying Supabase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
getWheel/getColorpassed the raw catch-all route segment straight into.eq('id', ...)on a uuid column. Any non-uuid path —/archive/colors/review(seen live in the Postgres error logs today:22P02 invalid input syntax for type uuid: "review"), crawler junk, or the wheel page's literal'noWheel'fallback — reached Postgres and threw. The client already swallowed the error into a not-found state, so the only symptom was server-side error noise.Fix
Validate the id against the repo's existing
UUID_REidiom (same regex as theserver/apiroutes) and returnnullbefore querying. User-visible behavior is unchanged — non-uuid paths land on the same not-found rendering as before, just without a Postgres round-trip.Tests
getWheel/getColortest call args to valid uuids (row fixture ids unchanged).nulland Supabase is never called.bun run teston both suites: 58 passed.🤖 Generated with Claude Code