Skip to content

fix(convex): throw ConvexError codes from customer/website ops (#2003) - #2294

Merged
Israeltheminer merged 2 commits into
mainfrom
fix/2003-customers-websites-convexerror
Jun 30, 2026
Merged

Israeltheminer merged 2 commits into
mainfrom
fix/2003-customers-websites-convexerror

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

Closes #2003

Problem

customers/* and websites/* mutations and actions threw bare throw 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

  • All throw sites now raise ConvexError with 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, …
  • REST mapping updated in 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 --noEmit exit 0, oxlint 0 errors, oxfmt --check clean (14 files).

Minor follow-up: both DUPLICATE_DOMAIN and WEBSITE_DUPLICATE_DOMAIN appear for the duplicate-domain case — worth unifying to one code in review.

Israeltheminer and others added 2 commits June 30, 2026 11:55
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.
@Israeltheminer
Israeltheminer merged commit e298607 into main Jun 30, 2026
30 of 31 checks passed
@Israeltheminer
Israeltheminer deleted the fix/2003-customers-websites-convexerror branch June 30, 2026 13:43
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.

Bug: Raw Error throws in customer/website mutations and actions not caught by Convex error boundary

1 participant