{"record":{"id":"82050987d6e0bc98","repo":"zeroclaw-labs/zeroclaw","slug":"grok-cli-env-passthrough-entry-name-is-invalid","errorCode":null,"errorMessage":"grok_cli env_passthrough entry `{name}` is invalid; expected [A-Za-z_][A-Za-z0-9_]*","messagePattern":"grok_cli env_passthrough entry `(.+?)` is invalid; expected \\[A-Za-z_\\]\\[A-Za-z0-9_\\]\\*","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-providers/src/grok_cli.rs","lineNumber":521,"sourceCode":"\n    fn validate_acp_stdout_limit(value: Option<usize>) -> anyhow::Result<usize> {\n        let limit = value.unwrap_or(acp::DEFAULT_ACP_STDOUT_LIMIT_BYTES);\n        if !(acp::MIN_ACP_STDOUT_LIMIT_BYTES..=acp::MAX_ACP_STDOUT_LIMIT_BYTES).contains(&limit) {\n            anyhow::bail!(\n                \"grok_cli max_acp_stdout_bytes must be between {} and {} bytes\",\n                acp::MIN_ACP_STDOUT_LIMIT_BYTES,\n                acp::MAX_ACP_STDOUT_LIMIT_BYTES\n            );\n        }\n        Ok(limit)\n    }\n\n    fn normalize_and_validate_env_passthrough(names: Vec<String>) -> anyhow::Result<Vec<String>> {\n        let mut normalized: Vec<String> = Vec::with_capacity(names.len());\n        for name in names {\n            let name = name.trim();\n            if !is_valid_env_var_name(name) {\n                anyhow::bail!(\n                    \"grok_cli env_passthrough entry `{name}` is invalid; expected [A-Za-z_][A-Za-z0-9_]*\"\n                );\n            }\n            if is_disallowed_provider_env_var(name) {\n                anyhow::bail!(\n                    \"grok_cli env_passthrough entry `{name}` is provider-owned \\\n                     (`XAI_*` other than `XAI_API_KEY`, and all `GROK_*`); \\\n                     other names (for example tool credentials) may be listed \\\n                     explicitly, and Grok CLI policy flags belong in `extra_args`\"\n                );\n            }\n            if !normalized\n                .iter()\n                .any(|existing| env_names_equal(existing.as_str(), name))\n            {\n                // Preserve the operator-supplied spelling; equality is\n                // case-insensitive on Windows when checking membership later.\n                normalized.push(name.to_string());","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-providers/src/grok_cli.rs#L503-L539","documentation":"Every env_passthrough entry must match [A-Za-z_][A-Za-z0-9_]* after trimming; normalize_and_validate_env_passthrough rejects malformed names before the child environment is assembled, preventing garbled or injected env assignments.","triggerScenarios":"Entries like 'FOO BAR', '1FOO', 'FOO-BAR', values containing '=', or entries that are empty after trim; Windows-style '%VAR%' names pasted from cmd docs.","commonSituations":"YAML/TOML lists pasted with quotes or trailing spaces; names copied from a shell export line including the value; locale-specific characters in names.","solutions":["Fix the entry to identifier form (letters, digits, underscore, not starting with a digit)","Drop empty entries; entries are trimmed, so remove stray whitespace-only items","If you meant a value assignment, use the CLI's own flag mechanism instead"],"exampleFix":"# before\nenv_passthrough = [\"FOO-BAR\", \"1BAZ\", \"\"]\n\n# after\nenv_passthrough = [\"FOO_BAR\", \"BAZ\"]","handlingStrategy":"validation","validationCode":"fn valid_env_var_name(name: &str) -> bool {\n    let mut chars = name.chars();\n    matches!(chars.next(), Some(c) if c.is_ascii_alphabetic() || c == '_')\n        && chars.all(|c| c.is_ascii_alphanumeric() || c == '_')\n}","typeGuard":"fn valid_env_var_name(name: &str) -> bool {\n    let mut chars = name.chars();\n    matches!(chars.next(), Some(c) if c.is_ascii_alphabetic() || c == '_')\n        && chars.all(|c| c.is_ascii_alphanumeric() || c == '_')\n}","tryCatchPattern":null,"preventionTips":["Lint env_passthrough lists in config CI","Paste names only, never KEY=VALUE pairs","Trim before validation since entries are trimmed by the provider"],"tags":["rust","zeroclaw","grok-cli","environment-variables","validation","configuration"],"backgroundTag":"invalid-env-var-name","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}