nikivdev/code · error
unexpected auth status: {}
Error message
unexpected auth status: {} What it means
In `login` (src/auth.rs:102) the device-flow poll loop matches known statuses (success, pending, expired, invalid) and bails on any other value via `other => bail!("unexpected auth status: {}", other)`. This is a forward-compatibility guard: the server returned a status string this CLI version does not understand. It usually indicates a server/client protocol mismatch.
Source
Thrown at src/auth.rs:102
}
let poll: DevicePollResponse = poll_response
.json()
.context("failed to parse device auth poll response")?;
match poll.status.as_str() {
"approved" => {
let token = poll
.token
.ok_or_else(|| anyhow!("device auth approved without token"))?;
env::save_ai_auth_token(token, Some(api_url.clone()))?;
println!("✓ Auth complete. You're ready to use Flow AI.");
return Ok(());
}
"pending" => continue,
"expired" => bail!("device code expired. Run `f auth` again."),
"invalid" => bail!("device code invalid. Run `f auth` again."),
other => bail!("unexpected auth status: {}", other),
}
}
bail!("device code expired. Run `f auth` again.")
}
fn open_in_browser(url: &str) {
#[cfg(target_os = "macos")]
{
let _ = std::process::Command::new("open").arg(url).status();
}
#[cfg(target_os = "linux")]
{
let _ = std::process::Command::new("xdg-open").arg(url).status();
}
#[cfg(not(any(target_os = "macos", target_os = "linux")))]View on GitHub (pinned to a747e741ae)
Solutions
- Upgrade the CLI to the latest version so it understands new auth statuses
- Check the printed status value for clues about what the server returned
- Verify the configured auth API URL points at the compatible server version
- If behind a proxy, bypass it and retry `f auth`
Example fix
// before
other => bail!("unexpected auth status: {}", other),
// after
"slow_down" => { std::thread::sleep(Duration::from_secs(5)); continue; }
other => bail!("unexpected auth status: {}", other), Defensive patterns
Strategy: try-catch
Try / catch
match result {
Err(e) if e.to_string().starts_with("unexpected auth status") => {
log_server_status(&e); // capture the raw status for diagnosis
eprintln!("CLI/server protocol mismatch — upgrade the CLI");
}
other => other?,
} Prevention
- Auto-update or pin CLI versions compatible with your auth server
- Log unexpected statuses to spot new server states early
- Test auth flows after any server deployment
When it happens
Trigger: The poll endpoint returns a status string other than "pending"/"expired"/"invalid"/success — e.g. a new server-side status like "slow_down" or "denied" added after this CLI version shipped, or a malformed response body.
Common situations: Auth server was updated to a newer protocol than the installed CLI; a proxy returns an HTML/error page parsed as an odd status; response shape changed between API versions.
Related errors
- device code invalid. Run `f auth` again.
- remote review unauthorized. Run `f auth` to login.
- gh {} failed: {}
- jj git push failed: {}
- failed to push PR head {} to any remote: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/561c9209c576e757.
Report an issue: GitHub.