Repository navigation
fix(account): delete identities and targets when deleting own account - #14208
Conversation
DELETE /v1/account left identity and target cleanup to the deletes worker. Signing up again with the same email before the worker ran hit the identity email check in POST /v1/account and returned general_bad_request. Delete them synchronously, as DELETE /v1/users/:userId already does. The session has no delete permission over every row, so the deletes skip authorization like the worker.
|
Review complete. No issues found — approved ✅. This PR extends account self-deletion so that the caller's OAuth identities and messaging targets are removed inline along with the user document, instead of relying solely on the async
One caveat noted during review but below the reporting threshold: the user document is deleted before the inline cascade, so a mid-batch cascade failure (e.g. the defensive Reviewed commit: 837aa2f |
🔵 Tier A · Mergeable after minor fixes
Account deletion now synchronously removes the user, OAuth identities, messaging targets, and sessions in an authorization-skipped transaction before queuing the remaining cleanup. A new E2E test uses a fresh project to cover mock OAuth sign-in, self-deletion, and immediate signup with the same email. Latest changes: The newest commits make synchronous cleanup transactional, include session deletion, and add the immediate same-email signup E2E regression.
Fix with agent prompt### Issue 1
app/controllers/api/account.php:574-575
**Add an E2E regression for immediate signup after OAuth account deletion**
The existing `AccountBase::testDeleteAccount` only checks the 204 response, so it still passes without this fix; the repository already has mock-provider OAuth E2E coverage. Please add the OAuth sign-in → self-delete → immediate same-email signup regression required by AGENTS.md's HTTP contract testing rule, including checking that the new account owns its email target.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 2
⏳ Still open from earlier reviews · 1
Reviewed the commits since |
| DeleteIdentities::delete($dbForProject, Query::equal('userInternalId', [$targetUser->getSequence()])); | ||
| DeleteTargets::delete($dbForProject, Query::equal('userInternalId', [$targetUser->getSequence()])); |
There was a problem hiding this comment.
Add an E2E regression for immediate signup after OAuth account deletion
The existing AccountBase::testDeleteAccount only checks the 204 response, so it still passes without this fix; the repository already has mock-provider OAuth E2E coverage. Please add the OAuth sign-in → self-delete → immediate same-email signup regression required by AGENTS.md's HTTP contract testing rule, including checking that the new account owns its email target.
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/controllers/api/account.php
Line: 574-575
Comment:
**Add an E2E regression for immediate signup after OAuth account deletion**
The existing `AccountBase::testDeleteAccount` only checks the 204 response, so it still passes without this fix; the repository already has mock-provider OAuth E2E coverage. Please add the OAuth sign-in → self-delete → immediate same-email signup regression required by AGENTS.md's HTTP contract testing rule, including checking that the new account owns its email target.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
If deleting identities or targets throws after the user document is gone, the request never reached the enqueue, leaving sessions, tokens and memberships without a cleanup job. Queue the job first; the worker deleting rows the request already removed is a no-op.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
| DeleteIdentities::delete($dbForProject, Query::equal('userInternalId', [$targetUser->getSequence()])); | ||
| DeleteTargets::delete($dbForProject, Query::equal('userInternalId', [$targetUser->getSequence()])); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Check with Jake, we might want this as part of one transaction
Delete the user, identities, targets and sessions together, then queue the deletes job for the rest. A failure rolls back to an intact account that can be deleted again, instead of a missing user whose remaining rows nothing will clean up.
The OAuth2 identity has to go with the account, or the same email is refused with general_bad_request until the deletes worker runs.
What does this PR do?
DELETE /v1/accountdeleted the user document and left identities, targets and sessions to the deletes worker. Until the worker ran, signing up again with the same email hit the identity email check inPOST /v1/accountand returned a genericgeneral_bad_request.This deletes the account's key rows (user, identities, targets, sessions) in one transaction, then queues the deletes job for everything else. A failure rolls back to an intact account that can be deleted again. The bulk deletes skip authorization, the same as the worker. The error stays generic on purpose (enumeration protection).
Closes #8135
Test Plan
New e2e
testCreateAccountAfterOAuth2AccountDelete: OAuth sign-in with the mock provider →DELETE /v1/account→ immediatePOST /v1/accountwith the same email returns 201. It fails with 400 on the code before this PR.Manual runs on a local stack, each one OAuth sign-in, self-delete, then an immediate signup with the same email:
general_bad_request×5Related PRs and Issues