{"record":{"id":"eaca556a7603ae42","repo":"Hmbown/CodeWhale","slug":"project-hooks-file-exceeds-the-1-mib-limit","errorCode":null,"errorMessage":"project hooks file exceeds the 1 MiB limit","messagePattern":"project hooks file exceeds the 1 MiB limit","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/hooks/config.rs","lineNumber":16,"sourceCode":"use serde::{Deserialize, Serialize};\nuse std::io::Read as _;\nuse std::path::{Path, PathBuf};\n\n/// Project hook files are executable configuration and must not become an\n/// unbounded startup allocation merely because a trusted repository supplied\n/// a very large file.\nconst PROJECT_HOOKS_FILE_MAX_BYTES: usize = 1024 * 1024;\n\nfn read_project_hooks_file(path: &Path) -> std::io::Result<String> {\n    let file = std::fs::File::open(path)?;\n    let mut contents = String::new();\n    file.take((PROJECT_HOOKS_FILE_MAX_BYTES + 1) as u64)\n        .read_to_string(&mut contents)?;\n    if contents.len() > PROJECT_HOOKS_FILE_MAX_BYTES {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            \"project hooks file exceeds the 1 MiB limit\",\n        ));\n    }\n    Ok(contents)\n}\n\n/// Events that can trigger hook execution\n#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]\n#[serde(rename_all = \"snake_case\")]\npub enum HookEvent {\n    /// Triggered when a new session starts\n    SessionStart,\n    /// Triggered when a session ends (quit, Ctrl+C)\n    SessionEnd,\n    /// Triggered before a user message is sent to the LLM\n    MessageSubmit,\n    /// Triggered before a tool is executed","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/hooks/config.rs#L1-L34","documentation":"Size guard in read_project_hooks_file: the project's hooks configuration file is larger than PROJECT_HOOKS_FILE_MAX_BYTES (1 MiB). Because hooks files are executable configuration read at startup, an oversized file is rejected to bound startup memory allocation from a possibly untrusted repo.","triggerScenarios":"Thrown at crates/tui/src/hooks/config.rs:16 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the hooks file below 1 MiB by removing unused hook entries or comments.","Split hooks into multiple smaller files if the project's hook configuration genuinely needs more space.","Check for accidental commits of large generated files at the hooks path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}