zeroclaw-labs/zeroclaw · error · anyhow::Error
Token cannot be empty
Error message
Token cannot be empty
What it means
In the quickstart `claude setup-token` inline flow, ZeroClaw prompts for the token the subcommand printed; input that is empty or only whitespace bails before anything is written to `providers.models.anthropic.<alias>.api_key`.
Source
Thrown at src/main.rs:7421
}
#[cfg(feature = "agent-runtime")]
async fn run_anthropic_setup_token_inline(alias: &str, config: &mut Config) -> Result<()> {
let status = tokio::process::Command::new("claude")
.arg("setup-token")
.status()
.await
.context("failed to run `claude setup-token`; is the Claude CLI installed and on PATH?")?;
if !status.success() {
bail!("`claude setup-token` exited with status {status}");
}
let token = read_auth_input(&t(
"cli-quickstart-auth-anthropic-token-prompt",
"Paste the token from `claude setup-token`",
))?;
if token.trim().is_empty() {
bail!("Token cannot be empty");
}
let path = format!("providers.models.anthropic.{alias}.api_key");
config.set_prop_persistent(&path, token.trim())?;
Box::pin(config.save_dirty()).await?;
println!(
"{}",
ta(
"cli-quickstart-auth-anthropic-saved",
&[("alias", alias)],
" Saved Claude setup token.",
)
);
Ok(())
}
#[allow(clippy::too_many_lines)]
#[cfg(feature = "agent-runtime")]View on GitHub (pinned to 88bb9c8533)
Solutions
- Re-run the flow and paste the full token printed by `claude setup-token`
- In scripts, skip the prompt entirely: `zeroclaw auth paste-token --model-provider anthropic --token <value>`
- Leading/trailing spaces are trimmed, so paste the whole value — only fully blank input is rejected
Example fix
# before: empty input at the 'Paste the token' prompt → bail # after claude setup-token # prints the token zeroclaw auth paste-token --model-provider anthropic --token "$TOKEN"
Defensive patterns
Strategy: validation
Validate before calling
read -r tok
[ -n "$(printf '%s' "$tok" | tr -d '[:space:]')" ] || { echo "empty token; aborting"; exit 1; } Prevention
- Pipe tokens from a secret store instead of prompting
- Treat a blank paste as an abort signal and restart the flow cleanly
- Never log the token while debugging the prompt
When it happens
Trigger: Pressing Enter (or pasting only whitespace) at the 'Paste the token from `claude setup-token`' prompt in run_anthropic_setup_token_inline.
Common situations: Non-interactive contexts where stdin is empty or closed (CI, piped scripts) so read_auth_input returns nothing; users pressing Enter to try to skip; clipboard paste failing silently.
Related errors
- `claude setup-token` exited with status {status}
- tag '{}' contains a comma, which is used as the tag separato
- empty bearer token
- Invalid JWT structure: expected 3 dot-separated parts
- empty session token
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/47100080bd56eb36.
Report an issue: GitHub.