fix(auth-server): handle account deletion failures with passkeys#20528
Open
vpomerleau wants to merge 1 commit intomainfrom
Open
fix(auth-server): handle account deletion failures with passkeys#20528vpomerleau wants to merge 1 commit intomainfrom
vpomerleau wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes account-deletion failures for users with registered passkeys by updating the auth DB deletion stored procedure order and ensuring failures are correctly surfaced to clients and observability systems (metrics + Sentry), rather than being silently swallowed.
Changes:
- Add
deleteAccount_23DB stored procedure (and bump schema patch level) to deletepasskeysbeforeaccountsto avoid FK constraint aborts. - Introduce
ACCOUNT_DELETION_FAILED(errno 239) and wire it through shared errors + Settings strings. - Improve deletion failure handling: propagate quick-delete failures (skip cloud-task enqueue on failure), add failure metrics + Sentry reporting, and tag Sentry user context for cloud-task requests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/fxa-shared/db/models/auth/base-auth.ts | Switches delete-account proc binding to deleteAccount_23. |
| packages/fxa-settings/src/lib/auth-errors/en.ftl | Adds localized message for errno 239. |
| packages/fxa-settings/src/lib/auth-errors/auth-errors.ts | Adds Settings-side mapping for ACCOUNT_DELETION_FAILED. |
| packages/fxa-auth-server/lib/routes/cloud-tasks.ts | Tags Sentry user with affected uid for cloud-task handlers. |
| packages/fxa-auth-server/lib/routes/account.spec.ts | Updates /account/destroy behavior expectations when quickDelete fails. |
| packages/fxa-auth-server/lib/account-delete.ts | Propagates quickDelete failures via AppError(239); adds failure metrics/Sentry reporting for cloud-task deletion path. |
| packages/fxa-auth-server/lib/account-delete.spec.ts | Adds/updates tests for failure metrics + Sentry reporting + errno 239 behavior. |
| packages/db-migrations/databases/fxa/target-patch.json | Bumps DB patch level to 192. |
| packages/db-migrations/databases/fxa/patches/patch-192-191.sql | Adds rollback patch stub for level 192. |
| packages/db-migrations/databases/fxa/patches/patch-191-192.sql | Creates deleteAccount_23 and updates patch level. |
| libs/accounts/passkey/PASSKEY_FIELDS.md | Updates documentation reference to deleteAccount_23. |
| libs/accounts/errors/src/constants.ts | Adds ERRNO.ACCOUNT_DELETION_FAILED = 239. |
| libs/accounts/errors/src/app-error.ts | Adds AppError.accountDeletionFailed() producing errno 239. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bcolsson
approved these changes
May 6, 2026
Because: - deleteAccount_22 deleted accounts before passkeys, violating the passkeys.uid FK constraint and aborting the transaction for any user with a registered passkey. - The route swallowed the failure silently, returning success to the user even though the account was not deleted. This commit: - Adds deleteAccount_23 with passkeys deleted before accounts. - Throws AppError.accountDeletionFailed (errno 239) so the UI shows a meaningful error instead of "Unexpected error". Closes #FXA-13676
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.
Because
This pull request
Issue that this pull request solves
Closes: FXA-13676
Checklist
Put an
xin the boxes that applyHow to review (Optional)
Screenshots (Optional)
Please attach the screenshots of the changes made in case of change in user interface.
Other information (Optional)
This bug only impacts environments with passkey feature enabled.