Bug: api.js retries 409 Conflict responses (duplicate lead submissions) #126

Closed
opened 2026-05-17 21:27:37 -05:00 by null · 0 comments
Owner

Problem

api.js retryFetch logic retries on 429 (rate limit) and 5xx errors, but does NOT explicitly exclude 409 Conflict from retry.

When the UNIQUE constraint on leads.email is eventually added (see #120), a duplicate email will return 409. The current retry logic treats 409 as a generic 4xx error and does NOT retry it (because it only retries 5xx and 429). So this is actually fine for now.

However, the 409 handler on the client side (Contact.jsx) does NOT exist. When a duplicate email is submitted, the user sees a generic error toast from api.js: "API error: Conflict" — not the friendly "A lead with this email already exists" message from the server.

The server returns { error: 'Duplicate lead', message: 'A lead with this email already exists' } but the client error handler only reads errorData.error, showing just "Duplicate lead" — not the more helpful message.

Fix

Add 409 Conflict handling in Contact.jsx:

onError: (error) => {
  if (error.response?.status === 409) {
    toast.error('A submission with this email already exists. We\'ll be in touch!')
  } else {
    toast.error(error.message || 'Failed to submit form. Please try again.')
  }
}

Files

  • src/pages/Contact.jsx — mutation onError handler
  • src/lib/api.js — already handles 4xx correctly (no retry)

Severity

Low — currently academic since #120 means duplicates are allowed. But once #120 is fixed, users need proper 409 messaging.

## Problem api.js retryFetch logic retries on 429 (rate limit) and 5xx errors, but does NOT explicitly exclude 409 Conflict from retry. When the UNIQUE constraint on leads.email is eventually added (see #120), a duplicate email will return 409. The current retry logic treats 409 as a generic 4xx error and does NOT retry it (because it only retries 5xx and 429). So this is actually fine for now. However, the 409 handler on the client side (Contact.jsx) does NOT exist. When a duplicate email is submitted, the user sees a generic error toast from api.js: "API error: Conflict" — not the friendly "A lead with this email already exists" message from the server. The server returns `{ error: 'Duplicate lead', message: 'A lead with this email already exists' }` but the client error handler only reads `errorData.error`, showing just "Duplicate lead" — not the more helpful message. ## Fix Add 409 Conflict handling in Contact.jsx: ```jsx onError: (error) => { if (error.response?.status === 409) { toast.error('A submission with this email already exists. We\'ll be in touch!') } else { toast.error(error.message || 'Failed to submit form. Please try again.') } } ``` ## Files - src/pages/Contact.jsx — mutation onError handler - src/lib/api.js — already handles 4xx correctly (no retry) ## Severity Low — currently academic since #120 means duplicates are allowed. But once #120 is fixed, users need proper 409 messaging.
null closed this issue 2026-05-17 21:52:13 -05:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: null/Queue-North-Website#126
No description provided.