{"record":{"id":"c3096bf45a73c3ea","repo":"ultraworkers/claw-code","slug":"file-is-too-large-bytes-max-bytes","errorCode":null,"errorMessage":"file is too large ({} bytes, max {} bytes)","messagePattern":"file is too large \\((.+?) bytes, max (.+?) bytes\\)","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"rust/crates/runtime/src/file_ops.rs","lineNumber":195,"sourceCode":"    pub num_matches: Option<usize>,\n    #[serde(rename = \"appliedLimit\")]\n    pub applied_limit: Option<usize>,\n    #[serde(rename = \"appliedOffset\")]\n    pub applied_offset: Option<usize>,\n}\n\n/// Reads a text file and returns a line-windowed payload.\npub fn read_file(\n    path: &str,\n    offset: Option<usize>,\n    limit: Option<usize>,\n) -> io::Result<ReadFileOutput> {\n    let absolute_path = normalize_path(path)?;\n\n    // Check file size before reading\n    let metadata = fs::metadata(&absolute_path)?;\n    if metadata.len() > MAX_READ_SIZE {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\n                \"file is too large ({} bytes, max {} bytes)\",\n                metadata.len(),\n                MAX_READ_SIZE\n            ),\n        ));\n    }\n\n    // Detect binary files\n    if is_binary_file(&absolute_path)? {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            \"file appears to be binary\",\n        ));\n    }\n\n    let content = fs::read_to_string(&absolute_path)?;","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/ultraworkers/claw-code/blob/08106b0c3771ef5b4a5aa176acccd460e88b7325/rust/crates/runtime/src/file_ops.rs#L177-L213","documentation":"`read_file` (runtime/src/file_ops.rs:195) rejects any file whose `fs::metadata().len()` exceeds `MAX_READ_SIZE`, a 10 MiB constant (file_ops.rs:14). The check runs on the WHOLE file before offset/limit windowing, so requesting a tiny line window of an oversized file still fails. `ErrorKind::InvalidData`.","triggerScenarios":"Calling the Read tool on an 11 MiB log, minified JS bundle, dataset CSV, or core dump — even with `offset`/`limit` set to a small slice; TOCTOU size change between metadata and read is not the issue here, the pre-check is unconditional.","commonSituations":"Agents trying to inspect large generated artifacts (lockfiles, snapshots, training logs); CI outputs; files that grew past 10 MiB since a previous successful read.","solutions":["Slice the file with the Bash tool instead: `sed -n '1,200p' big.log` or `tail -n 200 big.log`.","Split/rotate the oversized file so each part is under 10 MiB, then read the parts.","If you own the build, raise `MAX_READ_SIZE` in file_ops.rs and rebuild — but prefer slicing to avoid loading 10+ MiB into context."],"exampleFix":"# before\nRead(file=\"build/server.log\", offset=0, limit=100)   # file is too large (11258992 bytes, max 10485760 bytes)\n\n# after\nBash(command=\"sed -n '1,100p' build/server.log\")","handlingStrategy":"validation","validationCode":"const MAX_READ_SIZE: u64 = 10 * 1024 * 1024; // must mirror file_ops.rs:14\n\nfn readable_by_tool(p: &Path) -> io::Result<bool> {\n    Ok(std::fs::metadata(p)?.len() <= MAX_READ_SIZE)\n}","typeGuard":null,"tryCatchPattern":"match read_file(path, offset, limit) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData\n        && e.to_string().contains(\"file is too large\") => { /* fall back to bash sed/tail slicing */ }\n    other => other,\n}","preventionTips":["Check file size before Read; the 10 MiB cap applies to the whole file even when you request a small line window","Slice big files via Bash (`sed -n`, `tail`) instead of Read","Rotate/truncate logs and generated artifacts"],"tags":["file-ops","read","size-limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"08106b0c3771ef5b4a5aa176acccd460e88b7325","analyzedAt":"2026-08-18T00:29:38.590Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}