{"record":{"id":"b3db88cc236cf6b0","repo":"Hmbown/CodeWhale","slug":"project-config-exceeds-the-1-mib-limit","errorCode":null,"errorMessage":"project config {} exceeds the 1 MiB limit","messagePattern":"project config (.+?) exceeds the 1 MiB limit","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":11166,"sourceCode":"        Err(err) => return Err(err),\n    };\n    let file_type = metadata.file_type();\n    if file_type.is_symlink() {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidInput,\n            \"project-scope config must not be a symlink\",\n        ));\n    }\n    if !file_type.is_file() {\n        return Ok(None);\n    }\n\n    let file = open_project_config_file(path)?;\n    let mut raw = String::new();\n    file.take(MAX_PROJECT_CONFIG_BYTES + 1)\n        .read_to_string(&mut raw)?;\n    if raw.len() as u64 > MAX_PROJECT_CONFIG_BYTES {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"project config {} exceeds the 1 MiB limit\", path.display()),\n        ));\n    }\n    Ok(Some(raw))\n}\n\n#[cfg(unix)]\nfn open_project_config_file(path: &Path) -> io::Result<std::fs::File> {\n    use std::os::unix::fs::OpenOptionsExt;\n\n    std::fs::OpenOptions::new()\n        .read(true)\n        .custom_flags(libc::O_NOFOLLOW)\n        .open(path)\n}\n\n#[cfg(not(unix))]","sourceCodeStart":11148,"sourceCodeEnd":11184,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L11148-L11184","documentation":"The project config reader enforces a 1 MiB (MAX_PROJECT_CONFIG_BYTES) size ceiling. It reads at most limit+1 bytes and errors if the content is larger, so a pathological or accidentally bloated config cannot consume unbounded memory. The error is InvalidData and includes the offending path.","triggerScenarios":"Loading a project config whose byte length exceeds MAX_PROJECT_CONFIG_BYTES (1 MiB) after open_project_config_file succeeds.","commonSituations":"A config file accidentally filled by a log or binary blob; committing a large generated config; a script appending to the config each run until it grows past 1 MiB.","solutions":["Inspect and trim the config at the reported path (delete duplicated or generated sections) to get under 1 MiB.","Move bulky data out of the config into separate data files and reference them.","Regenerate the config from its source template if it was corrupted or auto-appended to."],"exampleFix":"// before: 1.4 MiB config with embedded blob\ncache_data = \"AAAA....\"\n// after\ncache_data_file = \"./cache-data.bin\"  # keep config under 1 MiB","handlingStrategy":"validation","validationCode":"let size = std::fs::metadata(path)?.len();\nif size > 1024 * 1024 { eprintln!(\"{path:?} is {size} bytes; trim below 1 MiB\"); }","typeGuard":null,"tryCatchPattern":"match std::fs::read_to_string(path) {\n    Ok(s) if s.len() > 1024*1024 => eprintln!(\"config too large\"),\n    Ok(s) => parse(s),\n    Err(e) => eprintln!(\"read failed: {e}\"),\n}","preventionTips":["Keep configs declarative and small; never embed blobs or data dumps.","Watch for scripts that append to the config on every run.","Check config file size in CI as a lint."],"tags":["config","file-size","limit"],"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"}