{"record":{"id":"69f8889a199169f2","repo":"nikivdev/code","slug":"key-not-found","errorCode":null,"errorMessage":"Key '{}' not found","messagePattern":"Key '(.+?)' not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/env.rs","lineNumber":3870,"sourceCode":"\n    if vars.is_empty() {\n        bail!(\"No env vars found\");\n    }\n\n    match format {\n        \"json\" => {\n            let json = serde_json::to_string_pretty(&vars)?;\n            println!(\"{}\", json);\n        }\n        \"value\" => {\n            if keys.len() != 1 {\n                bail!(\"'value' format requires exactly one key\");\n            }\n            let key = &keys[0];\n            if let Some(value) = vars.get(key) {\n                print!(\"{}\", value); // No newline for piping\n            } else {\n                bail!(\"Key '{}' not found\", key);\n            }\n        }\n        \"env\" | _ => {\n            // Default: KEY=VALUE format\n            let mut sorted_keys: Vec<_> = vars.keys().collect();\n            sorted_keys.sort();\n            for key in sorted_keys {\n                let value = &vars[key];\n                // Escape for shell\n                let escaped = value.replace('\\\\', \"\\\\\\\\\").replace('\"', \"\\\\\\\"\");\n                println!(\"{}=\\\"{}\\\"\", key, escaped);\n            }\n        }\n    }\n\n    Ok(())\n}\n","sourceCodeStart":3852,"sourceCodeEnd":3888,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/env.rs#L3852-L3888","documentation":"Raised in the `value` output format when the single requested key is not present in the fetched env-var map. The fetch succeeded, but the server has no variable under that key name, so there is no value to print.","triggerScenarios":"`f env pull --format value --keys KEY` where KEY differs in spelling or case from the stored variable name, or the variable was never pushed / was deleted.","commonSituations":"Case-mismatch (API_URL vs apiUrl); referencing a key that exists locally in .env but was never pushed; key removed remotely by a teammate.","solutions":["Run `f env pull` (default format) to list available key names and copy the exact spelling.","Fix the key's case/spelling in --keys to match the stored variable.","Push the missing variable with `f env push` if it should exist."],"exampleFix":"// before\nf env pull --format value --keys API_URL\n// after: exact remote key name\nf env pull --format value --keys apiUrl","handlingStrategy":"validation","validationCode":"# confirm the key exists before requesting its value\nf env list | grep -qx \"^$KEY=\" || { echo \"key '$KEY' not found remotely\" >&2; exit 1; }\nVAL=$(f env pull --format value --keys \"$KEY\")","typeGuard":null,"tryCatchPattern":"// fail fast with the exact key named\nVAL=$(f env pull --format value --keys \"$KEY\") \\\n  || { echo \"could not read '$KEY'; run 'f env list' to see available keys\" >&2; exit 1; }","preventionTips":["Copy key names exactly from `f env list` output (mind case).","Keep local .env key names identical to what you push.","Re-list remote keys after teammates modify the environment."],"tags":["cli","environment","not-found","key-mismatch"],"backgroundTag":"missing-env-var","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}