Hmbown/CodeWhale · error · anyhow::Error
exceeds the byte workspace .env limit
Error message
{} exceeds the {} byte workspace .env limit What it means
The workspace .env is size-bounded by MAX_WORKSPACE_DOTENV_BYTES. After the link check, read_stable_workspace_dotenv compares metadata.len() against the cap and bails if the file is larger. This bounds memory and parse time for a file whose contents become credential inputs.
Solutions
- Trim the .env to only the variables Codewhale needs; remove unrelated or commented-out bulk content.
- Check the size with `wc -c .env` and split non-credential data into other files outside the workspace.
- Move large secret collections into your OS keychain/secret manager instead of a flat .env.
- Find what is appending to the file (scripts, sync jobs) and stop it.
Example fix
// before .env = 5 MB environment dump // after grep -E '^(API_KEY|MODEL|BASE_URL)=' big.env > .env # keep only needed keys
Defensive patterns
Strategy: validation
Validate before calling
// shell
[ "$(wc -c < .env)" -le 262144 ] || { echo '.env too large'; exit 1; } # adjust to MAX_WORKSPACE_DOTENV_BYTES Prevention
- Keep .env minimal: only variables Codewhale consumes.
- Store bulk secrets in a secret manager, not a flat file.
- Monitor for scripts appending to .env.
When it happens
Trigger: A workspace `.env` whose on-disk size (metadata.len()) exceeds MAX_WORKSPACE_DOTENV_BYTES when Codewhale loads workspace dotenv credentials.
Common situations: Dumping a full shell environment or a large secret bundle into .env, appending logs to .env by mistake, or an automated sync writing bulk data into the file.
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
- bundle at is bytes; the limit is bytes
- config file exceeds the 1 MiB limit
- could not be parsed safely
- is not a regular file
- is not valid UTF-8
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/470ca8f9dcfd877d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:2951
false
}
fn read_stable_workspace_dotenv(path: &Path) -> Result<Vec<u8>> {
let mut file = open_workspace_dotenv_without_following_links(path)?;
let metadata = file
.metadata()
.map_err(|error| anyhow!("could not inspect {}: {error}", path.display()))?;
if !metadata.is_file() {
bail!("{} is not a regular file", path.display());
}
if workspace_dotenv_has_multiple_links(&file, &metadata)? {
bail!(
"{} has multiple filesystem links, not a unique workspace-owned file",
path.display()
);
}
if metadata.len() > MAX_WORKSPACE_DOTENV_BYTES {
bail!(
"{} exceeds the {} byte workspace .env limit",
path.display(),
MAX_WORKSPACE_DOTENV_BYTES
);
}
let mut contents = Vec::with_capacity(metadata.len() as usize);
(&mut file)
.take(MAX_WORKSPACE_DOTENV_BYTES + 1)
.read_to_end(&mut contents)
.map_err(|error| anyhow!("could not read {}: {error}", path.display()))?;
if contents.len() as u64 > MAX_WORKSPACE_DOTENV_BYTES {
bail!(
"{} exceeds the {} byte workspace .env limit",
path.display(),
MAX_WORKSPACE_DOTENV_BYTES
);
}View on GitHub (pinned to 73e0f67d83)