{"record":{"id":"54eaf37b260108ff","repo":"warpdotdev/warp","slug":"user-should-be-logged-in","errorCode":null,"errorMessage":"User should be logged in","messagePattern":"User should be logged in","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/common.rs","lineNumber":115,"sourceCode":"\n/// Resolve the owner of a new cloud object. This resolution is based on the CLI `--team` and `--personal` flags.\n///\n/// If `team_flag` is true, attempts to get the current team UID (errors if not on a team).\n/// If `user_flag` is true, gets the current user's UID.\n/// Otherwise, defaults to team if available, falling back to user.\npub fn resolve_owner(team_flag: bool, user_flag: bool, ctx: &AppContext) -> anyhow::Result<Owner> {\n    if team_flag {\n        let team_id = UserWorkspaces::as_ref(ctx)\n            .sole_team_uid()\n            .ok_or_else(|| anyhow::anyhow!(\"User is not on a team\"))?;\n        return Ok(Owner::Team { team_uid: team_id });\n    }\n\n    if user_flag {\n        let user_id = AuthStateProvider::as_ref(ctx)\n            .get()\n            .user_id()\n            .ok_or_else(|| anyhow::anyhow!(\"User should be logged in\"))?;\n        return Ok(Owner::User { user_uid: user_id });\n    }\n\n    // Default: try team first, fall back to user\n    if let Some(team_uid) = UserWorkspaces::as_ref(ctx).sole_team_uid() {\n        return Ok(Owner::Team { team_uid });\n    }\n\n    log::warn!(\"Tried to default to creating team object, team could not be found.\");\n    let user_id = AuthStateProvider::as_ref(ctx)\n        .get()\n        .user_id()\n        .ok_or_else(|| anyhow::anyhow!(\"User should be logged in\"))?;\n    Ok(Owner::User { user_uid: user_id })\n}\n\n/// Refresh workspace metadata before executing an operation.\n///","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/common.rs#L97-L133","documentation":"`resolve_owner` with `user_flag=true` needs the logged-in user's uid from `AuthStateProvider`. `user_id()` returning None means there is no authenticated user, so `--personal` object creation fails with 'User should be logged in'.","triggerScenarios":"Passing `--personal` while the CLI has no auth session — never logged in, logged out, or the auth state is not yet hydrated — so `AuthStateProvider::as_ref(ctx).get().user_id()` is None.","commonSituations":"Fresh installs; CI runners with no credentials; expired or signed-out sessions; commands issued during early startup before auth loads.","solutions":["Log in (`warp login`) and retry","Check login status before scripting personal-object commands","For CI, provision credentials / API key access non-interactively","If auth is still loading at startup, retry after initialization completes"],"exampleFix":"# before\nwarp launch-configs create --personal cfg\n# after\nwarp login && warp launch-configs create --personal cfg","handlingStrategy":"validation","validationCode":"fn is_logged_in(ctx: &AppContext) -> bool {\n    AuthStateProvider::as_ref(ctx).get().user_id().is_some()\n}\n// Gate --personal flows on this; prompt login otherwise.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check auth state before object-creation commands","Provision credentials/API keys non-interactively in CI","Handle expired sessions with a re-login step"],"tags":["auth","login","cloud-objects","cli"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}