test: add API route error-handling consistency tests (#1118)#1119
Merged
sw-factory-automations merged 1 commit intoMay 16, 2026
Merged
Conversation
Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
✅ Post-merge verification skipped — |
Collaborator
Author
|
✅ UI verification skipped — no UI files changed. This PR only adds test files and updates |
This was referenced May 16, 2026
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.
Closes #1118
What
Adds structural convention tests that scan all API route files and verify each route handler that performs Supabase mutations also uses the standard error classification utilities. This catches the "forgot to add the check in the new endpoint" pattern that caused repeated Sentry noise bugs (#1004, #1013, #1083, #1084, #1114).
How
New test file
src/lib/sentry/api-route-consistency.test.tswith 6 tests:.insert()/.update()/.delete()/.upsert()or.rpc()must importcaptureSupabaseErrororcaptureApiError.insert()/.update()/.delete()must importisForeignKeyViolationErrororcaptureSupabaseError(which classifies FK violations internally)console.errorin catch blocks; must usecaptureApiErrororcaptureSupabaseError.from()or.rpc()must have catch blocks with Sentry captureAllowlist mechanism included for routes that intentionally skip checks (currently only
health/route.tswhich uses raw fetch without the Supabase client).Follows the same file-scanning pattern as the existing
sentry.test.tsbare-catch scanner.Testing
pnpm lint— no new warningspnpm typecheck— passespnpm test— 143 files, 1918 tests all passing