Repository navigation
fix(convex): throw ConvexError codes from customer/website ops (#2003) - #2294
Merged
Merged
Conversation
customers/* and websites/* mutations and actions threw bare `Error` for not-found, conflict, validation and auth rejections. These weren't caught by the Convex error boundary, so the UI and REST API got opaque 500s instead of actionable 4xx/ConvexError codes. Convert all throw sites to `ConvexError` with structured UPPER_SNAKE codes (CUSTOMER_NOT_FOUND, WEBSITE_NOT_FOUND, DUPLICATE_EMAIL, DUPLICATE_DOMAIN, EMAIL_REQUIRED, UNAUTHENTICATED, CRAWLER_*, …) and map them to HTTP status in the REST helper. Adds mutation_error_codes tests for both domains.
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 #2003
Problem
customers/*andwebsites/*mutations and actions threw barethrow new Error(...)for not-found, conflict, validation and auth rejections. Not caught by the Convex error boundary → opaque 500s in the UI and REST API instead of actionable 4xx codes.Fix
ConvexErrorwith structured UPPER_SNAKE codes:CUSTOMER_NOT_FOUND,WEBSITE_NOT_FOUND,DUPLICATE_EMAIL,DUPLICATE_DOMAIN,DUPLICATE_EXTERNAL_ID,EMAIL_REQUIRED,UNAUTHENTICATED,CRAWLER_WEBSITE_NOT_FOUND,CRAWLER_REGISTRATION_FAILED, …lib/rest/helpers.ts(NOT_FOUND→404, DUPLICATE/conflict→409, validation→400, UNAUTHENTICATED→401).Tests
New
customers/mutation_error_codes.test.ts+websites/mutation_error_codes.test.ts. Server suite green (35 tests);tsc --noEmitexit 0,oxlint0 errors,oxfmt --checkclean (14 files).