fix(contractor-onboarding) - handle not nested errors#1012
Merged
Conversation
Contributor
📦 Bundle Size Report
Size Limits
Largest Files (Top 5)
View All Files (312 total)
✅ Bundle size check passed |
Contributor
📊 Coverage Report
|
| Metric | Current | Previous | Change | Status |
|---|---|---|---|---|
| Lines | 89.99% | 90.03% | -0.04% | 🔴 |
| Statements | 89.66% | 89.70% | -0.04% | 🔴 |
| Functions | 87.70% | 87.69% | +0.01% | 🟢 |
| Branches | 80.02% | 80.06% | -0.04% | 🔴 |
Detailed Breakdown
Lines Coverage
- Covered: 3677 / 4086
- Coverage: 89.99%
- Change: -0.04% (2 lines)
Statements Coverage
- Covered: 3738 / 4169
- Coverage: 89.66%
- Change: -0.04% (2 statements)
Functions Coverage
- Covered: 998 / 1138
- Coverage: 87.70%
- Change: +0.01% (1 functions)
Branches Coverage
- Covered: 2283 / 2853
- Coverage: 80.02%
- Change: -0.04% (11 branches)
✅ Coverage check passed
Contributor
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
cammellos
approved these changes
May 14, 2026
Merged
jordividaller
pushed a commit
that referenced
this pull request
May 15, 2026
* fix(contractor-onboarding) - handle not nested errors * fix error handling docs * fix format * refactor(mutations) - handle nested structured * add docs * format
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.
Problem
Users were reporting a bug in the sandbox as the response structure wasn't the same one that we'll receive in partners env
When doing a
POST v1/contractors/employments/ae8556c6-5f18-405c-b789-f10f9b9372e7/contract-documentsagainst partners{ "error": { "errors": { "services_and_deliverables": { "error": [ "The text is non-compliant because it mentions 'weekly progress reviews' which implies a level of day-to-day supervision or control over the contractor's work, similar to performance reviews used for employees." ], "source": "REMOTE_AI", "skippable": true } } } }In theory on the sandbox env for them is when the error happens but I haven't been able to reproduce the exact same thing, I got returned the same as partners but this is what they were getting
{ "errors": { "services_and_deliverables": { "error": [ "The text is non-compliant because it includes language that implies weekly progress reviews, which can be interpreted as a form of day-to-day supervision or control over the Contractor's work." ], "source": "REMOTE_AI", "skippable": true } } }Solution
After giving two rounds of thinking, the way is normalize the errors so I always get returned the same thing
Second part is adding a type guard to get types and avoid reaching rawError
I added docs to cursor + bugbot
Note
Medium Risk
Changes the shape/typing of errors thrown by
mutationToPromise().mutateAsyncOrThrow, which can affect downstream catch blocks and onboarding flow behavior. Coverage is improved with new unit/integration tests, but error handling is a cross-cutting concern.Overview
Fixes mutation error handling by introducing a standardized
MutationErrorStructureplus anisMutationError()type guard, and by enrichingmutateAsyncOrThrowrejections withnormalizedErrors(from either nestederror.error.errorsor flaterror.errors) and an optionalresponse.Updates Contractor Onboarding’s AI-validation parsing to use the type guard and
normalizedErrors(replacing unsaferawErrordigging), and adds/updates tests to cover production-style 422 payloads and the new error shape expectations.Adds Cursor review guidance enforcing the new type-safe error-handling pattern via documentation and an always-on editor rule.
Reviewed by Cursor Bugbot for commit a17978f. Bugbot is set up for automated code reviews on this repo. Configure here.