{"record":{"id":"524c69f3c251a0ce","repo":"Hmbown/CodeWhale","slug":"private-lane-environment-exceeds-bytes-524c69","errorCode":null,"errorMessage":"private lane environment {} exceeds {} bytes","messagePattern":"private lane environment (.+?) exceeds (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/lane/src/runtime.rs","lineNumber":342,"sourceCode":"            reader.consume(take);\n            if ended_line {\n                break;\n            }\n        }\n        if line.is_empty() && reached_eof {\n            return Ok(());\n        }\n        append_child_output(&log_path, stream, &line)?;\n        if reached_eof {\n            return Ok(());\n        }\n    }\n}\n\nfn read_lane_environment(path: &Path) -> Result<Vec<(String, String)>> {\n    let metadata = fs::metadata(path).with_context(|| format!(\"stat {}\", path.display()))?;\n    if metadata.len() > MAX_ENVIRONMENT_BYTES {\n        bail!(\n            \"private lane environment {} exceeds {} bytes\",\n            path.display(),\n            MAX_ENVIRONMENT_BYTES\n        );\n    }\n    let bytes = fs::read(path).with_context(|| format!(\"read {}\", path.display()))?;\n    if bytes.len() as u64 > MAX_ENVIRONMENT_BYTES {\n        bail!(\n            \"private lane environment {} exceeds {} bytes\",\n            path.display(),\n            MAX_ENVIRONMENT_BYTES\n        );\n    }\n    let environment: Vec<(String, String)> =\n        serde_json::from_slice(&bytes).with_context(|| format!(\"parse {}\", path.display()))?;\n    for (key, _) in &environment {\n        if !valid_environment_key(key) {\n            bail!(\"invalid lane environment key {key:?}\");","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/lane/src/runtime.rs#L324-L360","documentation":"read_lane_environment first stats the private environment file and rejects it if the reported size exceeds MAX_ENVIRONMENT_BYTES, before reading. This is a pre-read sanity bound so a corrupt or hostile file cannot force an unbounded read into the proxy process.","triggerScenarios":"run_lane_log_proxy reading a lane environment file whose on-disk size (from fs::metadata) exceeds MAX_ENVIRONMENT_BYTES — typically a file written by an old/buggy writer or tampered with.","commonSituations":"Stale environment files left by an older version without size limits; external processes writing to the lane's private directory; corrupted state after a crashed writer.","solutions":["Delete the oversized environment file and restart the lane so start() rewrites it within bounds.","Verify no other process writes into the lane's private directory.","Re-run start() to regenerate the file; ensure the producing side respects MAX_ENVIRONMENT_BYTES.","If upgrading from an older version, clear stale lane state directories."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let size = std::fs::metadata(&env_path).map(|m| m.len()).unwrap_or(0);\nif size > MAX_ENVIRONMENT_BYTES { /* delete file and restart lane before reading */ }","typeGuard":null,"tryCatchPattern":"match read_result { Err(e) if e.to_string().contains(\"exceeds\") => { fs::remove_file(&env_path).ok(); restart_lane()?; } _ => ... }","preventionTips":["Clean stale lane runtime directories after upgrades.","Restrict write access to the lane's private directory to the owning process.","Regenerate environment files via start() rather than reusing old ones."],"tags":["environment","size-limit","file-read"],"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"}