Repository navigation
fix(platform): throw ConvexError for vendor not-found and conflict cases (#2004) - #2209
Merged
Merged
Conversation
Contributor
Author
Desk Review — Issue #2004 (vendors mutations: raw
|
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.
Summary
Resolves the remaining raw
Errorthrows in the vendors mutations (not-found guards and update/delete duplicate-conflict checks) that caused opaque 500s in both the UI and REST API paths.Issue #1993 covered the duplicate-add case on
createVendor; this PR covers the not-found and update/delete conflict cases that were left out.Changes
services/platform/convex/vendors/mutations.ts(client-callablemutationWithRLS): replacedthrow new Error(...)with structuredConvexError:updateVendornot-found →ConvexError({ code: 'VENDOR_NOT_FOUND' })updateVendoremail conflict →ConvexError({ code: 'DUPLICATE_EMAIL' })updateVendorexternalId conflict →ConvexError({ code: 'DUPLICATE_EXTERNAL_ID' })deleteVendornot-found →ConvexError({ code: 'VENDOR_NOT_FOUND' })services/platform/convex/vendors/internal_mutations.ts(REST path viawithRestAuth): same conversions forupdateVendor(incl. cross-tenant guard) anddeleteVendor(incl. cross-tenant guard).services/platform/convex/lib/rest/helpers.ts: extendedhttpStatusForConvexCodesowithRestAuthmapsVENDOR_NOT_FOUND → 404,DUPLICATE_EMAIL → 409,DUPLICATE_EXTERNAL_ID → 409instead of falling through to 500.services/platform/convex/vendors/mutation_error_codes.test.ts: new regression test asserting every not-found/conflict path throws aConvexErrorwith the correct code (both client and REST handlers).createVendorraw-error duplicates remain out of scope here (tracked by #1993).Verification
bunx vitest --run --project server convex/vendors/→ 16 passed (10 new)bunx tsc --noEmit→ clean for changed filesbunx oxlint --type-aware→ 0 warnings / 0 errorsoxfmt --check→ cleanCloses #2004