Hmbown/CodeWhale · error
No local {} API key was found in config, the secret store, o
Error message
No local {} API key was found in config, the secret store, or the environment What it means
Thrown by `codewhale cloud keys set <provider> --from-local`. resolve_local_key searches, in order: the provider config entry (providers.<kind>.api_key, resolving $VAR references; Deepseek also falls back to the top-level api_key), the local secret-store slot named for the provider kind, and the provider's environment variables. When every source is absent or whitespace-empty, there is nothing to upload and this error is returned.
Source
Thrown at crates/cli/src/cloud.rs:648
CloudCommand::Keys(keys) => match keys.command {
CloudKeysCommand::List => {
let user = client.me()?;
write_account(out, "Codewhale account keys.", profile, api_base, &user)?;
for provider in CloudProvider::ALL {
let state = user.model_keys.get(provider.slug());
if state.is_some_and(|state| state.configured) {
writeln!(out, "{}: set", provider.slug())?;
} else {
writeln!(out, "{}: not set", provider.slug())?;
}
}
Ok(())
}
CloudKeysCommand::Set(set) => {
let user = client.me()?;
let key = if set.from_local {
resolve_local_key(config, provider_secrets, set.provider)?.ok_or_else(|| {
anyhow!(
"No local {} API key was found in config, the secret store, or the environment",
set.provider.slug()
)
})?
} else if set.api_key_stdin {
key_reader(KeyReadMode::Stdin)?
} else {
key_reader(KeyReadMode::HiddenPrompt(set.provider.slug().to_string()))?
};
let key = key.trim().to_string();
validate_api_key(&key)?;
let label = validate_label(&set.label)?;
client.set_key(set.provider, &key, &label)?;
writeln!(
out,
"Saved {} for Codewhale account {} (profile {}).",
set.provider.slug(),
printable(&user.id),View on GitHub (pinned to 8880682c63)
Solutions
- Skip --from-local and supply the key directly: `codewhale cloud keys set <provider> --api-key-stdin` (or the hidden prompt)
- Export the provider's env var (e.g. OPENAI_API_KEY=sk-...) in the shell and rerun the same command
- Configure the key locally first (provider auth / api-key set) so the secret store has a value, then rerun --from-local
- Verify sources with `codewhale cloud keys status` and by inspecting the providers section of the config
Example fix
# before codewhale cloud keys set openai --from-local # error: no local key # after export OPENAI_API_KEY=sk-... codewhale cloud keys set openai --from-local # or: printf '%s' "$KEY" | codewhale cloud keys set openai --api-key-stdin
Defensive patterns
Strategy: validation
Validate before calling
# Verify a local key exists before attempting --from-local:
codewhale cloud keys status | grep -q "$(slug): set" \
|| export -n OPENAI_API_KEY 2>/dev/null \
|| [ -n "${OPENAI_API_KEY:-}" ] \
|| { echo "no local key; using stdin"; printf '%s' "$KEY" | codewhale cloud keys set openai --api-key-stdin; } Prevention
- In scripts, prefer --api-key-stdin over --from-local so behavior does not depend on machine state
- Run `codewhale cloud keys status` first to confirm which providers have local keys
- Remember Deepseek reads the top-level config api_key while others read providers.<kind>.api_key
- Trim env vars; whitespace-only values count as absent
When it happens
Trigger: Running `cloud keys set <provider> --from-local` on a machine where the provider was never configured: no config key, no secret-store entry, and no provider env var (e.g. OPENAI_API_KEY) set. Also when a $VAR config reference points at an unset variable, or the env var is set but empty.
Common situations: Fresh machine or container trying to migrate a key that only exists on a dev workstation; key stored under a different provider than the cloud provider's local_kind maps to; CI job that never injects the env var.
Related errors
- Secret storage write failed for {slot}: {err}. Refusing to w
- Secret storage snapshot failed for {slot}: {error}. Refusing
- Codewhale account API base URL must include a host
- The Codewhale service returned a verification URL without a
- Codewhale account request failed (HTTP {}, code {code})
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/7280aabc3bfd26f0.
Report an issue: GitHub.