web: name the failed account deletion stage on the response

TE
2d ago
+19-5

Summary

DELETE /api/account answered 500 {"error":"account_delete_retryable","retryable":true,"destroyedVms":0} three times in a row for a throwaway production account, and the account still exists. That body is the same for every stage from the PostHog step on (PostHog, Stack metadata, billing, TestFlight, identity leases and publications, VMs, networking and vault, cmux rows, Stack delete), and the stage it failed at is only in Sentry (deletion_stage tag, since #18928) and in server logs. No agent route can read either, so the failing step could not be found from the response.

This change sets an x-cmux-account-deletion-stage header with that stage on every failure response that has one: the retryable and non-retryable 500s and the hosted Subrouter 503. The body is unchanged. Stage names are fixed identifiers with no account data. The next retry then names the step to fix.

This is a diagnostic change, not the root-cause fix: the stage that fails for this account is still unknown. A follow-up PR fixes it once a retry reads the header.

Not ported to feat-cmux-next: cmux.com deploys from main, and next's copy of the route has diverged (about 100 changed lines).

Testing

cd web && bun test tests/account-route.test.ts: the three new header assertions (posthog, identity_publications_vms, stack_delete) fail at the test commit and pass at the head.

Observed / Not run

  • Observed: bun test tests/account-route.test.ts at the head: 102 pass, 0 fail (run 41533323175). With the header calls stripped from the route at the same head (the base behaviour): 99 pass, 3 fail, exactly the three new header assertions (run 41534123699).
  • Not run: no production retry yet. It needs this deploy.

Changelog

none

Agent session: agent session

🤖 Generated with Claude Code