nikivdev/code · error
missing CLOUDFLARE_ACCOUNT_ID; set it in shell env or Flow p
Error message
missing CLOUDFLARE_ACCOUNT_ID; set it in shell env or Flow personal env store
What it means
cloudflare_credentials loads CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN from the shell env or the Flow personal env store. If the API token is set but the account ID is not, the pair is incomplete and it bails. Both variables must be present together (or both absent to skip Cloudflare).
Source
Thrown at src/url_inspect.rs:909
fn timeout_from_secs(seconds: f64) -> Result<Duration> {
if !seconds.is_finite() || seconds <= 0.0 {
bail!("timeout must be a positive finite number");
}
Ok(Duration::from_secs_f64(seconds))
}
fn cloudflare_credentials() -> Result<Option<(String, String)>> {
let account_id = load_secret_env_var("CLOUDFLARE_ACCOUNT_ID")?;
let api_token = load_secret_env_var("CLOUDFLARE_API_TOKEN")?;
match (account_id, api_token) {
(Some(account_id), Some(api_token)) => Ok(Some((account_id, api_token))),
(None, None) => Ok(None),
(Some(_), None) => {
bail!("missing CLOUDFLARE_API_TOKEN; set it in shell env or Flow personal env store")
}
(None, Some(_)) => {
bail!("missing CLOUDFLARE_ACCOUNT_ID; set it in shell env or Flow personal env store")
}
}
}
fn load_secret_env_var(key: &str) -> Result<Option<String>> {
if let Ok(value) = std::env::var(key) {
let trimmed = value.trim();
if !trimmed.is_empty() {
return Ok(Some(trimmed.to_string()));
}
}
let primary = flow_env::get_personal_env_var(key)
.with_context(|| format!("failed to load {key} from Flow personal env store"));
match primary {
Ok(Some(value)) => {
let trimmed = value.trim();
if !trimmed.is_empty() {View on GitHub (pinned to a747e741ae)
Solutions
- Set CLOUDFLARE_ACCOUNT_ID in the shell environment (export CLOUDFLARE_ACCOUNT_ID=...) or via `flow env set CLOUDFLARE_ACCOUNT_ID=...`.
- Copy the account ID from the Cloudflare dashboard (right side of the overview page) into the env.
- Verify the exact variable name CLOUDFLARE_ACCOUNT_ID is used, not CF_ACCOUNT_ID or similar.
- Ensure the value is non-empty after trimming — blank values count as missing.
- Alternatively unset CLOUDFLARE_API_TOKEN too if you intended to disable Cloudflare integration (None/None is accepted).
Example fix
// before: partial credentials in env // CLOUDFLARE_API_TOKEN=cf-token-here // after: export both // CLOUDFLARE_ACCOUNT_ID=abc123 // CLOUDFLARE_API_TOKEN=cf-token-here
Defensive patterns
Strategy: validation
Validate before calling
let token = std::env::var("CLOUDFLARE_API_TOKEN").ok().filter(|v| !v.trim().is_empty());
let account = std::env::var("CLOUDFLARE_ACCOUNT_ID").ok().filter(|v| !v.trim().is_empty());
if token.is_some() && account.is_none() {
return Err(anyhow!("missing CLOUDFLARE_ACCOUNT_ID; set it in shell env or Flow personal env store"));
} Try / catch
match inspect_url(url, &opts) {
Err(e) if e.to_string().contains("missing CLOUDFLARE_ACCOUNT_ID") => {
eprintln!("Cloudflare creds incomplete; skipping CF path");
inspect_url_no_cloudflare(url, &opts)?
}
other => other?,
} Prevention
- Always set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN as a pair.
- Add a startup env preflight that checks both-or-neither.
- Copy the account ID from the Cloudflare dashboard when creating the token.
- Unset both variables if you intend to disable Cloudflare integration.
When it happens
Trigger: Calling inspect_url or crawl_url when CLOUDFLARE_API_TOKEN is present (non-empty) in shell env or Flow store, but CLOUDFLARE_ACCOUNT_ID is unset or empty.
Common situations: Exporting only the API token after following token-creation docs; account ID left in a different machine's env or forgotten in the Flow store; variable renamed (e.g. CF_ACCOUNT_ID) so the expected name is empty; empty export in CI secrets.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- missing CLOUDFLARE_API_TOKEN; set it in shell env or Flow pe
- could not resolve commit report directory
- OPENROUTER_API_KEY not set. Get one at https://openrouter.ai
- Docs template root not found: {}
- bun, npx, or npm is required to run wrangler
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/1af0501de267f5da.
Report an issue: GitHub.