Skip to content

fix(ui): show HubSpot submission errors inline (blocked email, invali… - #164

Open
maccomaccomaccomacco wants to merge 1 commit into
mainfrom
fix/hubspot-form-error-messages
Open

maccomaccomaccomacco wants to merge 1 commit into
mainfrom
fix/hubspot-form-error-messages

Conversation

@maccomaccomaccomacco

Copy link
Copy Markdown
Collaborator

Problem

When HubSpot rejects a submission (e.g. a free email provider, which the Sales form blocks), the site shows a generic "Form submission failed. Please try again" plus a "review the highlighted fields" banner with nothing highlighted. Users have no way to know what to fix.

What changes

  • lib/hubspot.ts: 4xx responses from the HubSpot submissions API now throw HubSpotSubmissionError carrying HubSpot's error list (errorType + message). 5xx and network errors are unchanged.
  • api/hubspot/submit/route.ts: on a HubSpot rejection, responds 400 with errors: [{ code, message, field }]; the field is derived from the error type (email errors) or from HubSpot's message. Server errors still return 500 with the generic message.
  • HubSpotSsrForm.tsx: field-level errors are shown inline under the field with a readable message per code (BLOCKED_EMAIL, INVALID_EMAIL, REQUIRED_FIELD, fallback). The "review the highlighted fields" banner now only shows when a field is actually highlighted. Errors with no matching field fall back to the existing alert, but with the precise reason.
  • locales/en.json: new forms.errors.* strings.

No change to the success flow or to HubSpot.

How to test

On the preview, submit /contact-sales with a gmail.com address: expect "Please use your work email address. Free email providers are not accepted." under Work Email, no red banner, no generic alert. Submit with a work email: unchanged success flow (no lead is created by the gmail test, HubSpot rejects it).

@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
website-ui Ready Ready Preview Oct 19, 2026 12:34pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — e7520dd4 Deployed Oct 19, 2026 by vercel[bot]
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.

1 participant