Hmbown/CodeWhale · error · io::Error
project config exceeds the 1 MiB limit
Error message
project config {} exceeds the 1 MiB limit What it means
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.
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.
Example fix
// before: 1.4 MiB config with embedded blob cache_data = "AAAA...." // after cache_data_file = "./cache-data.bin" # keep config under 1 MiB
Defensive patterns
Strategy: validation
Validate before calling
let size = std::fs::metadata(path)?.len();
if size > 1024 * 1024 { eprintln!("{path:?} is {size} bytes; trim below 1 MiB"); } Try / catch
match std::fs::read_to_string(path) {
Ok(s) if s.len() > 1024*1024 => eprintln!("config too large"),
Ok(s) => parse(s),
Err(e) => eprintln!("read failed: {e}"),
} Prevention
- 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.
When it happens
Trigger: Loading a project config whose byte length exceeds MAX_PROJECT_CONFIG_BYTES (1 MiB) after open_project_config_file succeeds.
Common situations: 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.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- MCP config exceeds the 1 MiB limit
- project hooks file exceeds the 1 MiB limit
- bundle at is bytes; the limit is bytes
- config file exceeds the 1 MiB limit
- evidence metadata exceeds limit
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/b3db88cc236cf6b0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:11166
Err(err) => return Err(err),
};
let file_type = metadata.file_type();
if file_type.is_symlink() {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
"project-scope config must not be a symlink",
));
}
if !file_type.is_file() {
return Ok(None);
}
let file = open_project_config_file(path)?;
let mut raw = String::new();
file.take(MAX_PROJECT_CONFIG_BYTES + 1)
.read_to_string(&mut raw)?;
if raw.len() as u64 > MAX_PROJECT_CONFIG_BYTES {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
format!("project config {} exceeds the 1 MiB limit", path.display()),
));
}
Ok(Some(raw))
}
#[cfg(unix)]
fn open_project_config_file(path: &Path) -> io::Result<std::fs::File> {
use std::os::unix::fs::OpenOptionsExt;
std::fs::OpenOptions::new()
.read(true)
.custom_flags(libc::O_NOFOLLOW)
.open(path)
}
#[cfg(not(unix))]View on GitHub (pinned to 73e0f67d83)