Skip to content

feat(forms): migrate account emails form to new form system#108384

Merged
JonasBa merged 7 commits intomasterfrom
jb/settings/email-addresses
Feb 20, 2026
Merged

feat(forms): migrate account emails form to new form system#108384
JonasBa merged 7 commits intomasterfrom
jb/settings/email-addresses

Conversation

@JonasBa
Copy link
Copy Markdown
Member

@JonasBa JonasBa commented Feb 17, 2026

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

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 17, 2026
@linear
Copy link
Copy Markdown

linear bot commented Feb 17, 2026

@JonasBa JonasBa requested a review from a team February 17, 2026 21:41
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lovely ❤️

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JonasBa JonasBa force-pushed the jb/settings/email-addresses branch from da709d4 to 72fefa7 Compare February 18, 2026 18:07
JonasBa and others added 5 commits February 19, 2026 18:37
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]>
Comment on lines +56 to +64
if (error instanceof RequestError) {
const errorMessage = error.responseJSON?.detail;
if (typeof errorMessage === 'string') {
addErrorMessage(errorMessage);
} else {
addErrorMessage(errorMessage?.message ?? t('An unknown error occurred.'));
}
}
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JonasBa JonasBa merged commit 0b7adc7 into master Feb 20, 2026
63 checks passed
@JonasBa JonasBa deleted the jb/settings/email-addresses branch February 20, 2026 18:19
priscilawebdev pushed a commit that referenced this pull request Feb 24, 2026
## 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]>
mchen-sentry pushed a commit that referenced this pull request Feb 24, 2026
## 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]>
@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants