warpdotdev/warp · error

Could not determine user ID. Are you logged in?

Error message

Could not determine user ID. Are you logged in?

What it means

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.

Source

Thrown at app/src/ai/agent_sdk/admin.rs:190

}

/// Singleton model that provides a `ModelContext` for the `whoami` command's async work.
struct WhoamiRunner;

impl warpui::Entity for WhoamiRunner {
    type Event = ();
}

impl SingletonEntity for WhoamiRunner {}

/// Print information about the currently authenticated principal.
pub fn whoami(ctx: &mut AppContext, output_format: OutputFormat) -> Result<()> {
    let auth_state = AuthStateProvider::as_ref(ctx).get();
    let principal_type = auth_state.principal_type().unwrap_or_default();

    let user_uid = auth_state
        .user_id()
        .ok_or_else(|| anyhow::anyhow!("Could not determine user ID. Are you logged in?"))?;
    let uid = user_uid.as_string();
    let uid = uid
        .strip_prefix("serviceAccount:")
        .map(String::from)
        .unwrap_or(uid);

    let mut info = WhoamiOutput {
        uid,
        principal_type: match principal_type {
            PrincipalType::User => "user",
            PrincipalType::ServiceAccount => "service_account",
        },
        display_name: auth_state.display_name(),
        email: match principal_type {
            PrincipalType::User => auth_state.user_email().filter(|e| !e.is_empty()),
            PrincipalType::ServiceAccount => None,
        },
        team_uids: vec![],

View on GitHub (pinned to e72fd7aacb)

Solutions

  1. Complete the login (device/web auth) flow before running whoami
  2. Wait for authentication to finish if login was just started
  3. Verify which principal is authenticated; whoami specifically needs a user id
Defensive patterns

Strategy: validation

Validate before calling

let auth_state = AuthStateProvider::as_ref(ctx).get();
if auth_state.user_id().is_none() {
    // route the user to login instead of invoking whoami()
}

Try / catch

match admin::whoami(ctx, output_format) {
    Ok(()) => {}
    Err(err) if err.to_string().contains("Could not determine user ID") => {
        // start the login flow, then re-run whoami
    }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16). Data as JSON: /api/errors/6914d67443af72b5. Report an issue: GitHub.