{"record":{"id":"6914d67443af72b5","repo":"warpdotdev/warp","slug":"could-not-determine-user-id-are-you-logged-in","errorCode":null,"errorMessage":"Could not determine user ID. Are you logged in?","messagePattern":"Could not determine user ID\\. Are you logged in\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/admin.rs","lineNumber":190,"sourceCode":"}\n\n/// Singleton model that provides a `ModelContext` for the `whoami` command's async work.\nstruct WhoamiRunner;\n\nimpl warpui::Entity for WhoamiRunner {\n    type Event = ();\n}\n\nimpl SingletonEntity for WhoamiRunner {}\n\n/// Print information about the currently authenticated principal.\npub fn whoami(ctx: &mut AppContext, output_format: OutputFormat) -> Result<()> {\n    let auth_state = AuthStateProvider::as_ref(ctx).get();\n    let principal_type = auth_state.principal_type().unwrap_or_default();\n\n    let user_uid = auth_state\n        .user_id()\n        .ok_or_else(|| anyhow::anyhow!(\"Could not determine user ID. Are you logged in?\"))?;\n    let uid = user_uid.as_string();\n    let uid = uid\n        .strip_prefix(\"serviceAccount:\")\n        .map(String::from)\n        .unwrap_or(uid);\n\n    let mut info = WhoamiOutput {\n        uid,\n        principal_type: match principal_type {\n            PrincipalType::User => \"user\",\n            PrincipalType::ServiceAccount => \"service_account\",\n        },\n        display_name: auth_state.display_name(),\n        email: match principal_type {\n            PrincipalType::User => auth_state.user_email().filter(|e| !e.is_empty()),\n            PrincipalType::ServiceAccount => None,\n        },\n        team_uids: vec![],","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/admin.rs#L172-L208","documentation":"whoami() (app/src/ai/agent_sdk/admin.rs:190) reads the current AuthStateProvider state and requires a user id: auth_state.user_id() returning None produces this anyhow error, which is returned to the caller before any output is printed. The auth state is either unauthenticated or authenticated as a principal that carries no user id. It is a precondition failure, not a network or server error.","triggerScenarios":"Invoking the whoami admin subcommand while logged out, while login is still in flight, or with an auth state whose principal has no user_id.","commonSituations":"Fresh install with no completed login; whoami invoked immediately after launch before the AuthManager reaches an authenticated state; service-account or degraded auth state without a user id.","solutions":["Complete the login (device/web auth) flow before running whoami","Wait for authentication to finish if login was just started","Verify which principal is authenticated; whoami specifically needs a user id"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let auth_state = AuthStateProvider::as_ref(ctx).get();\nif auth_state.user_id().is_none() {\n    // route the user to login instead of invoking whoami()\n}","typeGuard":null,"tryCatchPattern":"match admin::whoami(ctx, output_format) {\n    Ok(()) => {}\n    Err(err) if err.to_string().contains(\"Could not determine user ID\") => {\n        // start the login flow, then re-run whoami\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Gate whoami and other principal-dependent commands behind a logged-in check","Wait for the auth state to be populated (login completed) before invoking admin commands"],"tags":["auth","whoami","cli","precondition"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}