{"record":{"id":"08058a45462f801d","repo":"nikivdev/code","slug":"no-env-keys-configured-add-cloudflare-env-keys-or","errorCode":null,"errorMessage":"No env keys configured. Add cloudflare.env_keys or cloudflare.env_vars to flow.toml.","messagePattern":"No env keys configured\\. Add cloudflare\\.env_keys or cloudflare\\.env_vars to flow\\.toml\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/env.rs","lineNumber":2599,"sourceCode":"    let flow_path = find_flow_toml(&cwd)\n        .ok_or_else(|| anyhow::anyhow!(\"flow.toml not found. Run `f init` first.\"))?;\n    let cfg = config::load(&flow_path)?;\n\n    let cf_cfg = cfg\n        .cloudflare\n        .as_ref()\n        .context(\"No [cloudflare] section in flow.toml\")?;\n\n    let mut required = Vec::new();\n    let mut seen = HashSet::new();\n    for key in cf_cfg.env_keys.iter().chain(cf_cfg.env_vars.iter()) {\n        if seen.insert(key.clone()) {\n            required.push(key.clone());\n        }\n    }\n\n    if required.is_empty() {\n        bail!(\n            \"No env keys configured. Add cloudflare.env_keys or cloudflare.env_vars to flow.toml.\"\n        );\n    }\n\n    println!(\"Checking required env vars for '{}'...\", environment);\n    let existing = match fetch_project_env_vars(environment, &required) {\n        Ok(vars) => vars,\n        Err(err) => {\n            let msg = format!(\"{err:#}\");\n            if msg.contains(\"Project not found.\") {\n                println!(\"  (project not found yet; will create on first set)\");\n                HashMap::new()\n            } else {\n                return Err(err);\n            }\n        }\n    };\n    let var_keys: HashSet<String> = cf_cfg.env_vars.iter().cloned().collect();","sourceCodeStart":2581,"sourceCodeEnd":2617,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/env.rs#L2581-L2617","documentation":"Raised by the env-check flow when, after collecting keys from flow.toml's `cloudflare.env_keys` and/or `cloudflare.env_vars`, the required set is empty. The check exists to verify that all configured keys are present in the cloud project environment, so with nothing configured there is nothing to validate and the CLI bails.","triggerScenarios":"Running the env-check command against a project whose flow.toml lacks both `cloudflare.env_keys` and `cloudflare.env_vars` sections, or where both are present but empty/deduplicated to nothing.","commonSituations":"Fresh projects whose flow.toml was scaffolded without env config; renamed config sections after a version change; commented-out env_keys block; checking the wrong project whose toml has no env settings.","solutions":["Add `cloudflare.env_keys = [\"KEY_A\", \"KEY_B\"]` (or `cloudflare.env_vars`) to flow.toml and re-run the check.","Uncomment or restore the env_keys/env_vars section if it was removed or commented out.","Confirm you are checking the intended project/environment — one whose flow.toml actually declares env keys."],"exampleFix":"# before (flow.toml)\n[cloudflare]\n# env_keys = []\n# after\n[cloudflare]\nenv_keys = [\"API_KEY\", \"DB_URL\"]","handlingStrategy":"validation","validationCode":"// Parse flow.toml and verify env keys are declared before running the check:\nlet cfg: TomlValue = toml::from_str(&fs::read_to_string(\"flow.toml\")?)?;\nlet keys = cfg.get(\"cloudflare\")\n    .and_then(|c| c.get(\"env_keys\").or_else(|| c.get(\"env_vars\")));\nif keys.map(|k| k.as_array().map_or(true, |a| a.is_empty())).unwrap_or(true) {\n    bail!(\"flow.toml has no cloudflare.env_keys/env_vars configured\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include `cloudflare.env_keys` in the flow.toml template for new projects.","Add a lint step that validates flow.toml sections before env-check in CI.","After upgrading the CLI, check for renamed config sections in release notes.","Keep env_keys/env_vars uncommented and non-empty in every environment's flow.toml."],"tags":["configuration","flow-toml","env-vars","validation"],"backgroundTag":"missing-config-key","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}