{"record":{"id":"77696d3e7af63569","repo":"warpdotdev/warp","slug":"authentication-failed-err","errorCode":null,"errorMessage":"Authentication failed: {err:#}","messagePattern":"Authentication failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/admin.rs","lineNumber":70,"sourceCode":"            }\n            AuthManagerEvent::AuthFailed(_) => {\n                if !started_device_auth {\n                    // Refresh failed - start a fresh device auth flow.\n                    started_device_auth = true;\n                    AuthManager::handle(ctx).update(ctx, |auth_manager, ctx| {\n                        auth_manager.authorize_device(ctx);\n                    });\n                } else {\n                    // Device auth failed.\n                    let err_msg = match event {\n                        AuthManagerEvent::AuthFailed(err) => {\n                            format!(\"Authentication failed: {err:#}\")\n                        }\n                        _ => \"Authentication failed\".to_string(),\n                    };\n                    ctx.terminate_app(\n                        TerminationMode::ForceTerminate,\n                        Some(Err(anyhow::anyhow!(err_msg))),\n                    );\n                }\n            }\n            AuthManagerEvent::ReceivedDeviceAuthorizationCode {\n                verification_url,\n                verification_url_complete,\n                user_code,\n            } => {\n                if let Some(url) = verification_url_complete {\n                    println!(\"To log in, open this URL in your browser:\\n{url}\");\n                } else {\n                    println!(\n                        \"To log in, visit {verification_url} and enter this code: {user_code}\"\n                    );\n                }\n            }\n            _ => {}\n        },","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/admin.rs#L52-L88","documentation":"Raised in the agent-sdk admin device-login flow (app/src/ai/agent_sdk/admin.rs:70) when the AuthManager emits AuthManagerEvent::AuthFailed during authorize_device. The underlying error is embedded with {err:#} (anyhow alternate Debug), and the app is immediately force-terminated (TerminationMode::ForceTerminate) with that error, so the process exits non-zero. It means the authentication backend rejected the flow, not that CLI arguments were wrong.","triggerScenarios":"Running an admin/agent-sdk command that triggers authorize_device, and the AuthManager later emits AuthFailed(err): expired or reused device code, revoked credentials, or the auth server returning failure mid device-authorization.","commonSituations":"Stored credentials revoked after a password change or device deauthorization; auth server unreachable or erroring mid-flow; a stale half-completed device flow being resumed; locked keychain so prior state could not be restored.","solutions":["Re-run the command to start a fresh device-authorization flow and complete it in the browser promptly","Verify network access to the auth and verification endpoints (proxy, VPN, firewall rules)","Sign out and sign back in to reset stored credentials, then retry","If it persists, read the embedded {err:#} detail for the backend reason and check auth service status"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let auth_state = AuthStateProvider::as_ref(ctx).get();\nif auth_state.user_id().is_none() {\n    // complete device auth before running admin commands that call authorize_device\n}","typeGuard":null,"tryCatchPattern":"// Auth failures arrive as events, not Results — decide between re-auth and surfacing:\nmatch event {\n    AuthManagerEvent::AuthFailed(err) => {\n        // optionally retry authorize_device(ctx) once before terminating with Err(anyhow!(\"Authentication failed: {err:#}\"))\n    }\n    other => { /* forward to remaining handlers */ }\n}","preventionTips":["Complete device-auth flows promptly; device codes expire and reuse triggers AuthFailed","Reset stored credentials (sign out/in) after account password or device changes","Treat AuthFailed as retryable once before surfacing it as terminal"],"tags":["auth","device-auth","cli","force-terminate"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}