{"record":{"id":"3ea05322ae25bb07","repo":"Hmbown/CodeWhale","slug":"uses-variable-expansion-workspace-env-values","errorCode":null,"errorMessage":"{} uses variable expansion; workspace .env values must be literal to prevent ambient-secret substitution","messagePattern":"(.+?) uses variable expansion; workspace \\.env values must be literal to prevent ambient-secret substitution","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":2834,"sourceCode":"                return Err(anyhow!(\n                    \"could not inspect {}: {error}\",\n                    candidate.display()\n                ));\n            }\n        }\n        if ancestor == boundary {\n            break;\n        }\n    }\n    Ok(None)\n}\n\nfn load_workspace_dotenv_credentials_from_path(path: &Path) -> Result<WorkspaceDotenvReport> {\n    let contents = read_stable_workspace_dotenv(path)?;\n    let text = std::str::from_utf8(&contents)\n        .map_err(|_| anyhow!(\"{} is not valid UTF-8\", path.display()))?;\n    if dotenv_has_variable_expansion(text) {\n        bail!(\n            \"{} uses variable expansion; workspace .env values must be literal to prevent ambient-secret substitution\",\n            path.display()\n        );\n    }\n\n    let mut report = WorkspaceDotenvReport {\n        path: path.to_path_buf(),\n        ..WorkspaceDotenvReport::default()\n    };\n    let entries = dotenvy::from_read_iter(std::io::Cursor::new(contents))\n        .collect::<std::result::Result<Vec<_>, _>>()\n        .map_err(|_| anyhow!(\"{} could not be parsed safely\", path.display()))?;\n    for entry in entries {\n        let (key, value) = entry;\n        if !is_workspace_dotenv_credential_key(&key) {\n            report.ignored.insert(key);\n            continue;\n        }","sourceCodeStart":2816,"sourceCodeEnd":2852,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L2816-L2852","documentation":"Workspace .env files are loaded to source provider credentials, but only literal values are accepted. If the file text contains variable-expansion syntax (e.g. ${VAR} or $VAR), load_workspace_dotenv_credentials_from_path rejects the whole file, because expansion could substitute ambient environment values — including unrelated secrets — into what look like literal config values.","triggerScenarios":"Placing a .env at the workspace root whose values contain $VAR or ${VAR} interpolation, then starting Codewhale which attempts to load workspace dotenv credentials.","commonSituations":"Copying a docker-compose-style .env with ${VAR} syntax into the workspace, inheriting a team .env that uses expansion, or shell-generated .env files that interpolate values.","solutions":["Replace ${VAR}/$VAR references in the workspace .env with their literal resolved values.","Move expansion-dependent values to your real environment (export in the shell) instead of the .env file.","Keep expansion-using .env files outside the workspace so they are not picked up.","Strip or comment out the offending line dotenv_has_variable_expansion flags."],"exampleFix":"// before (.env)\nAPI_KEY=${OPENAI_API_KEY}\n// after (.env)\nAPI_KEY=sk-literal-value-here","handlingStrategy":"validation","validationCode":"// shell\ngrep -nE '\\$\\{?[A-Za-z_][A-Za-z0-9_]*\\}?' .env && echo 'expansion not allowed in workspace .env' && exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write literal values only in workspace .env files; resolve variables before saving.","Never copy docker-compose/CI .env files with ${VAR} syntax into the workspace.","Put interpolation-dependent values in the real process environment instead."],"tags":["dotenv","env","security","config"],"backgroundTag":"invalid-env-var-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}