fix(e2e): report a 2FA-verify 5xx accurately, not as a rejected code #498
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/BUNYIP-496-e2e-2fa-5xx-diagnostic"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
The E2E TOTP helper
e2e/lib/login.ts:fillTotpStepsubmits a code and, on any rendered login error box, treats it as a rejected code: it waits out the TOTP step and retries once, then throws "TOTP rejected on both attempts ... the e2e account's enrolled 2FA secret likely does not match E2E_TOTP_SECRET, or the server clock is skewed".But bunyip-web renders the SAME
[class*="text-destructive"]error box for a server 5xx (the generic "An unexpected error occurred. Please try again later.", BUNYIP-477) as for a real code rejection ("Invalid verification code"). WhenPOST /v1/auth/2fa/verify5xx's (observed 2026-08-06: auser_totpdecryption failure on staging -APP_ENCRYPTION_KEYrotated with an emptyAPP_ENCRYPTION_KEY_PREV, soTotpService::verify_code->key_set.decryptreturnsAppError::internal),readLoginErrorreturns the generic message, the loop treats it as a rejection, wastes a step-wait retry, and throws the misleading secret/clock conclusion. The real cause (a 500) is hidden, and the retry burns2fa_verifyrate-limit budget for nothing.Goal
fillTotpStepdistinguishes a server 5xx from a real code rejection and reports the truth, so an E2E failure points at the actual cause.Proposed approach
In
fillTotpStep, afterreadLoginErrorreturns a non-null message, branch on it:/unexpected error|try again later/i), throw immediately with an accurate message (the code was submitted, bunyip-api 5xx'd onPOST /v1/auth/2fa/verify, check the server error-log - most likely auser_totpdecryption / encryption-key-state failure). Do NOT step-wait-retry: a fresh code cannot fix a server error.Alternatives considered
Acceptance criteria
fillTotpStepthrow an accurate "server error on /v1/auth/2fa/verify" diagnostic (naming the likely decryption / key cause), with no step-wait retry.2fa_verifycaps).