fix(checkout): preserve server validation errors on contact field blur - #13730
Open
detail-app[bot] wants to merge 1 commit into
Open
fix(checkout): preserve server validation errors on contact field blur#13730detail-app[bot] wants to merge 1 commit into
detail-app[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Preview Environment |
detail-app
Bot
force-pushed
the
detail/bug-fix/fix-checkout-preserve-server-validation-errors-on-2793e2
branch
from
August 14, 2026 13:52
dc353ff to
f17b17c
Compare
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.
Detail bug report: View on Detail
Summary
Related Issue: polarsource/feedback#381
Fixes a regression where server-side validation errors on checkout contact fields (email/name) were immediately cleared after being set, preventing buyers from seeing inline feedback when blurring those fields.
What
captureContactinCheckoutForm.tsxnow clears field errors before the update request and does not clear them on failure, matching the pattern already used byaddTaxIDand the address watcher in the same file.CheckoutForm.test.tsxcovering: server validation errors remaining visible after a rejected update, and stale errors being cleared while new server errors appear on retry.Why
captureContactcalledupdate({...}).catch(() => clearErrors(name)). TheCheckoutFormProvider'supdatesets validation errors viasetError/setValidationErrorsand then throws. The.catchhandler wiped the just-set errors, so buyers never saw onBlur server validation feedback — notably email deliverability checks that only the API can perform. Errors still appeared at checkout confirmation, but the immediate field-level feedback was defeated.How
Switched
captureContactto theclearErrors-before / no-clear-on-failure idiom used by every otherupdatecaller in the component (addTaxID,clearTaxID, the addresswatcher,updateBusinessCustomer,onPaymentElementChange):Testing
CheckoutForm.test.tsx, 382 across the@polar-sh/checkoutpackage), typecheck, lint, and format all pass. The two new regression tests fail against the original buggy code and pass with the fix.setValidationErrorsbefore throwing) is covered byCheckoutFormProvider.test.tsxand confirmed live:PATCH /v1/checkouts/client/<cs>with an undeliverable email returns HTTP 422 with the validation detail.test@example.com), blurred the field, and confirmed the validation error appears and stays visible. Correcting to a valid email cleared the error. Reverting the fix reproduced the bug (error cleared immediately), confirming the test catches the regression. No unhandled promise rejections occurred.dev striperequires interactive OAuth to a personal sandbox). This is a credential precondition unrelated to the fix; the contact-field validation behavior is independent of Stripe and was fully verified end-to-end.Checklist
uv run task lint && uv run task lint_types)Automatic Fixes PRs can be configured here.