Repository navigation
Make account deletion cleanup durable - #9117
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba4d63a9c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| logger.warning(f'account_deletion handler: non-actionable task for {uid}, claim_status={claim_status}') | ||
| return JSONResponse(status_code=200, content={'status': 'dropped', 'reason': claim_status}) | ||
|
|
||
| ok = await run_blocking(cleanup_executor, background_wipe_user_data, uid) |
There was a problem hiding this comment.
Avoid marking queued wipes as running
At this point the preceding claim_deletion_wipe_for_task has already changed the marker to running, but the actual wipe is only submitted to cleanup_executor here. If the four cleanup workers are occupied by long deletions, another task can sit queued until the 1500s request timeout and be cancelled before its worker starts; retries then see a fresh running marker and return 409 until the 6-hour stale window, delaying the account wipe. Keep the marker in a queued/retrying state until the cleanup function actually starts, or claim running from inside the worker.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
3 issues found across 17 files
Confidence score: 3/5
- In
backend/utils/twilio_service.py, the strict deletion path can treat anydelete_caller_id(...)=Falseas a hard failure, so account-deletion retries may get stuck after a partial Twilio cleanup and never converge. Before merging, make the strict flow idempotent by handling expected Twilio error codes as already-deleted/non-fatal outcomes. - In
backend/database/users.py, the claim transaction marks a wipe job asrunningbefore work actually starts incleanup_executorvia the router handler, which can leave jobs stranded if the executor never picks them up. Add a guard (for example, a heartbeat/timeout requeue or only flipping torunningat actual start) before merging. backend/utils/twilio_service.pynow has overlapping logic between the new function anddelete_user_caller_ids, which raises drift risk if Twilio cleanup behavior changes in one path but not the other. Reduce risk by extracting a shared helper with configurable failure policy so both paths stay consistent.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Reviewed the remaining account-deletion wipe thread against the current PR code and did not make a code change. Finding:
Verification:
No review thread was resolved because no new code change was needed. |
## Summary Closes #9760. - Makes production account deletion fail closed: a deletion intent is durably recorded with an opaque wipe job ID before the wipe can be dispatched, and production startup rejects inline or incomplete Cloud Tasks configuration. - Dispatches only the opaque job ID to the dedicated account-deletion queue; the handler resolves the user server-side and drops unknown, ambiguous, terminal, and unsupported legacy payloads before any mutation. - Adds reconciliation for persisted-but-undispatched intents, validates the GKE/Cloud Run deployment contract, and gives deletion tasks an account-deletion-specific OIDC audience. ## Root cause and recurrence The deletion workflow previously relied on inline execution as a reachable deployment mode and accepted a payload that could identify a user directly. A crash or configuration drift between the delete request and its side effects could therefore leave a deletion incomplete without a durable, safely replayable dispatch contract. This follows the same dispatch/reliability failure class addressed in #5088, #6750, #7640, #8405, #9117, and #9632. The durable guard is now the persisted wipe-job identity plus production-only Cloud Tasks configuration validation, queue payload minimization, dedicated OIDC audience verification, and reconciliation through the same dispatcher. ## Verification - `cd backend && ENCRYPTION_SECRET=local-test-secret BACKEND_PYTEST_WORKERS=1 bash test.sh` — passed all 603 isolated unit-test files. - `cd backend && PATH="/tmp/omi-predeploy-9760/bin:$PATH" bash scripts/pre-deploy-check.sh` — passed (69 tests); validates dev/prod runtime and deploy contracts. - `make preflight` — passed. - Exercised the controlled recovery path: persisted intent -> injected enqueue crash -> reconciler dispatch -> first handler completion -> repeat delivery no-op. This is covered by `test_persisted_wipe_recovers_after_enqueue_crash_and_handler_runs_once`. No live Cloud Task was dispatched because this PR does not authorize a deployment mutation. ## Review Sol review completed before opening. It identified an OIDC audience-isolation issue; the fix uses `ACCOUNT_DELETION_TASKS_OIDC_AUDIENCE` (defaulting only to the dedicated deletion handler URL) for both task creation and verification. A second independent Sol review after rebasing identified the deploy-order compatibility path for queued legacy UID tasks; the resolved branch accepts the former sync audience only for those legacy payloads and drops job-ID payloads before resolution or mutation.
Summary
Fixes #8405.
ACCOUNT_DELETION_DISPATCH_MODE=cloud_tasks, with API success returned only after the deletion marker is persisted and the wipe task enqueue succeeds.Validation
PYTHON=.venv/bin/python bash test-preflight.shpassed with optional integration warnings only.python -m pytest tests/services/users/test_account_deletion.py tests/routers/test_users.py tests/unit/test_sync_cloud_tasks.py tests/unit/test_delete_account_stripe_cancel.py tests/unit/test_delete_account_purge_storage.py tests/unit/test_twilio_account_deletion.py tests/unit/test_claim_deletion_wipe_txn.py -q-> 91 passed.python scripts/scan_import_time_side_effects.py-> 0 violations.python scripts/scan_async_blockers.py-> 0 selected blocking findings.python scripts/check_module_stub_pollution.py-> 0 violations.python scripts/validate-backend-runtime-env.py --env dev --check-workflowspassed.python scripts/validate-backend-runtime-env.py --env prod --check-workflowspassed.Notes
scripts/check_response_model_coverage.pystill fails on unrelated pre-existing untyped routes instaged_tasks.py.