feat(forms): migrate account emails form to new form system#108384
feat(forms): migrate account emails form to new form system#108384
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
da709d4 to
72fefa7
Compare
Replaces Form/JsonForm/accountEmailsFields with useScrapsForm + Zod validation. Uses useMutation + fetchMutation for the POST submission, invalidates the email list query on success, and resets the field after a successful add.
…gs search Wrap the add-email form with <FormSearch route="/settings/account/emails/"> so the email field is indexed by SettingsSearch via the generated field registry. Co-Authored-By: Claude <[email protected]>
62ba9e4 to
8671246
Compare
| if (error instanceof RequestError) { | ||
| const errorMessage = error.responseJSON?.detail; | ||
| if (typeof errorMessage === 'string') { | ||
| addErrorMessage(errorMessage); | ||
| } else { | ||
| addErrorMessage(errorMessage?.message ?? t('An unknown error occurred.')); | ||
| } | ||
| } | ||
| }, |
There was a problem hiding this comment.
Bug: The form for adding an email silently swallows all errors and incorrectly resets the form, misleading the user into thinking the submission was successful.
Severity: CRITICAL
Suggested Fix
Remove the .then().catch() chain from the onSubmit handler. Instead, await the mutation.mutateAsync(value) call inside a try...catch block. In the try block, reset the form on success. In the catch block, display a generic error message to the user using addErrorMessage. This ensures all errors are caught and properly reported to the user.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: static/app/views/settings/account/accountEmails.tsx#L56-L64
Potential issue: The `onSubmit` handler for the email addition mutation includes a
`.catch(() => {})` block that silently swallows all errors, including network errors or
other non-`RequestError` failures. Following this silent catch, the subsequent `.then()`
block executes, which resets the form. This behavior gives the user the false impression
that their email was added successfully when the operation actually failed. This masks
the underlying error from the user, preventing them from knowing the action needs to be
retried.
## Changes Migrates the **Add Secondary Emails** form in account settings from the legacy `Form`/`JsonForm` system to the new TanStack-based form system. - Replaces `Form`, `JsonForm`, and the `accountEmailsFields` data file with `useScrapsForm` and a Zod schema (`z.string().email()`) - Uses `useMutation` + `fetchMutation` for the POST submission - Invalidates the email list query on success so the list refreshes automatically - Resets the field after a successful add via `formApi.reset()` - Deletes the now-unused `static/app/data/forms/accountEmails.tsx` data file Fix DE-933 --------- Co-authored-by: Claude <[email protected]>
## Changes Migrates the **Add Secondary Emails** form in account settings from the legacy `Form`/`JsonForm` system to the new TanStack-based form system. - Replaces `Form`, `JsonForm`, and the `accountEmailsFields` data file with `useScrapsForm` and a Zod schema (`z.string().email()`) - Uses `useMutation` + `fetchMutation` for the POST submission - Invalidates the email list query on success so the list refreshes automatically - Resets the field after a successful add via `formApi.reset()` - Deletes the now-unused `static/app/data/forms/accountEmails.tsx` data file Fix DE-933 --------- Co-authored-by: Claude <[email protected]>
Changes
Migrates the Add Secondary Emails form in account settings from the legacy
Form/JsonFormsystem to the new TanStack-based form system.Form,JsonForm, and theaccountEmailsFieldsdata file withuseScrapsFormand a Zod schema (z.string().email())useMutation+fetchMutationfor the POST submissionformApi.reset()static/app/data/forms/accountEmails.tsxdata fileFix DE-933