nikivdev/code · warning · anyhow::Error
No [cloudflare] or [storage] env keys configured in flow.tom
Error message
No [cloudflare] or [storage] env keys configured in flow.toml
What it means
Bail-out at the end of the env-key listing/export routine: after checking all configured sources, neither `[cloudflare]` env keys nor `[storage]` env keys were found in flow.toml, and no earlier code path printed results and returned. The library raises this so the user knows their flow.toml simply has no env keys configured for either subsystem.
Source
Thrown at src/env.rs:3202
println!(" (no variables)");
} else {
for variable in &env_cfg.variables {
match variable.default.as_deref() {
Some(default) if !default.is_empty() => {
println!(" {} = {}", variable.key, format_default_hint(default));
}
Some(_) => println!(" {} (default: empty)", variable.key),
None => println!(" {}", variable.key),
}
}
}
println!();
}
return Ok(());
}
anyhow::bail!("No [cloudflare] or [storage] env keys configured in flow.toml");
}
/// List env vars for this project.
fn list(environment: &str) -> Result<()> {
if local_env_enabled() {
let target = resolve_env_target()?;
let label = env_target_label(&target);
let vars = read_local_env_vars(&target, environment)?;
println!("Space: {}", label);
println!("Environment: {}", environment);
println!("Backend: local");
println!("─────────────────────────────");
if vars.is_empty() {
println!("No env vars set.");
return Ok(());
}View on GitHub (pinned to a747e741ae)
Solutions
- Add env keys to the `[cloudflare]` section in flow.toml (e.g. `env = { MY_KEY = "value" }`)
- Add env keys to the `[storage]` section in flow.toml
- Check flow.toml section names for typos so the parser actually sees [cloudflare] or [storage]
- If intentionally empty, treat empty output as normal rather than running the listing command
Example fix
// before (flow.toml) [project] name = "my-app" // after (flow.toml) [project] name = "my-app" [cloudflare.env] MY_API_KEY = "xxx"
Defensive patterns
Strategy: validation
Validate before calling
let toml = std::fs::read_to_string("flow.toml")?;
if !toml.contains("[cloudflare]") && !toml.contains("[storage]") {
anyhow::bail!("flow.toml needs [cloudflare] or [storage] env keys");
} Type guard
fn has_env_keys(cfg: &Config) -> bool {
cfg.cloudflare.as_ref().map_or(false, |c| !c.env.is_empty())
|| cfg.storage.as_ref().map_or(false, |s| !s.env.is_empty())
} Try / catch
match list_env_keys() {
Err(e) if e.to_string().contains("No [cloudflare] or [storage]") => {
eprintln!("No env keys configured yet — nothing to list.");
}
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Seed new projects with at least one env key in [cloudflare.env]
- Double-check section name spelling ([cloudflare], not [cloudflair])
- Treat empty env output as expected for fresh projects instead of scripting around the error
- Run config lint as part of onboarding
When it happens
Trigger: Running the env key listing command on a project whose flow.toml defines no env keys under `[cloudflare]` and none under `[storage]`; the function falls through past the early-return `Ok(())` and reaches the final `anyhow::bail!`.
Common situations: Brand-new project before any env keys were added; flow.toml trimmed of all env config; typo'd section names (e.g. `[cloudflair]`) so the parser sees none of the expected keys.
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
- No bootstrap secrets configured. Add cloudflare.bootstrap_se
- expected [{}] to be a table in global flow config
- FLOW_CODEX_MAPLE_LOCAL_ENDPOINT and FLOW_CODEX_MAPLE_LOCAL_I
- FLOW_CODEX_MAPLE_HOSTED_ENDPOINT and FLOW_CODEX_MAPLE_HOSTED
- FLOW_CODEX_MAPLE_TRACES_ENDPOINTS count ({}) does not match
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/32b64d49bc2762a3.
Report an issue: GitHub.