{"record":{"id":"470ca8f9dcfd877d","repo":"Hmbown/CodeWhale","slug":"exceeds-the-byte-workspace-env-limit","errorCode":null,"errorMessage":"{} exceeds the {} byte workspace .env limit","messagePattern":"(.+?) exceeds the (.+?) byte workspace \\.env limit","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":2951,"sourceCode":"    false\n}\n\nfn read_stable_workspace_dotenv(path: &Path) -> Result<Vec<u8>> {\n    let mut file = open_workspace_dotenv_without_following_links(path)?;\n    let metadata = file\n        .metadata()\n        .map_err(|error| anyhow!(\"could not inspect {}: {error}\", path.display()))?;\n    if !metadata.is_file() {\n        bail!(\"{} is not a regular file\", path.display());\n    }\n    if workspace_dotenv_has_multiple_links(&file, &metadata)? {\n        bail!(\n            \"{} has multiple filesystem links, not a unique workspace-owned file\",\n            path.display()\n        );\n    }\n    if metadata.len() > MAX_WORKSPACE_DOTENV_BYTES {\n        bail!(\n            \"{} exceeds the {} byte workspace .env limit\",\n            path.display(),\n            MAX_WORKSPACE_DOTENV_BYTES\n        );\n    }\n\n    let mut contents = Vec::with_capacity(metadata.len() as usize);\n    (&mut file)\n        .take(MAX_WORKSPACE_DOTENV_BYTES + 1)\n        .read_to_end(&mut contents)\n        .map_err(|error| anyhow!(\"could not read {}: {error}\", path.display()))?;\n    if contents.len() as u64 > MAX_WORKSPACE_DOTENV_BYTES {\n        bail!(\n            \"{} exceeds the {} byte workspace .env limit\",\n            path.display(),\n            MAX_WORKSPACE_DOTENV_BYTES\n        );\n    }","sourceCodeStart":2933,"sourceCodeEnd":2969,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L2933-L2969","documentation":"The workspace .env is size-bounded by MAX_WORKSPACE_DOTENV_BYTES. After the link check, read_stable_workspace_dotenv compares metadata.len() against the cap and bails if the file is larger. This bounds memory and parse time for a file whose contents become credential inputs.","triggerScenarios":"A workspace `.env` whose on-disk size (metadata.len()) exceeds MAX_WORKSPACE_DOTENV_BYTES when Codewhale loads workspace dotenv credentials.","commonSituations":"Dumping a full shell environment or a large secret bundle into .env, appending logs to .env by mistake, or an automated sync writing bulk data into the file.","solutions":["Trim the .env to only the variables Codewhale needs; remove unrelated or commented-out bulk content.","Check the size with `wc -c .env` and split non-credential data into other files outside the workspace.","Move large secret collections into your OS keychain/secret manager instead of a flat .env.","Find what is appending to the file (scripts, sync jobs) and stop it."],"exampleFix":"// before\n.env = 5 MB environment dump\n// after\ngrep -E '^(API_KEY|MODEL|BASE_URL)=' big.env > .env   # keep only needed keys","handlingStrategy":"validation","validationCode":"// shell\n[ \"$(wc -c < .env)\" -le 262144 ] || { echo '.env too large'; exit 1; }  # adjust to MAX_WORKSPACE_DOTENV_BYTES","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep .env minimal: only variables Codewhale consumes.","Store bulk secrets in a secret manager, not a flat file.","Monitor for scripts appending to .env."],"tags":["dotenv","file-size","limits","config"],"backgroundTag":"file-size-limit-exceeded","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"}