Hmbown/CodeWhale · error
Codewhale-owned credential file
Error message
Codewhale-owned credential file {} exceeds the {} byte safety limit What it means
read_codewhale_owned_to_string applies the same bounded-read guard as the external-grant reader to files owned by Codewhale itself (below its credentials directory). If the file is larger than MAX_EXTERNAL_CREDENTIAL_BYTES, the read fails closed instead of returning the contents, protecting against corrupted or hijacked credential files.
Solutions
- Inspect the file at the path in the message; delete and re-authenticate so Codewhale rewrites a fresh credential file.
- Find what is growing the file (concurrent writers, sync conflict copies) and stop it before re-creating the credential.
- Ensure only Codewhale writes under its credentials directory; don't redirect other outputs there.
- Restore the file from a known-good backup if available, keeping size within the limit.
Example fix
// before: token file grown to megabytes by repeated appends $ rm ~/.codewhale/credentials/<file> && codewhale auth login // recreated within limit
Defensive patterns
Strategy: validation
Validate before calling
let meta = std::fs::metadata(path)?;
if meta.len() > codewhale::tui::external_credentials::MAX_EXTERNAL_CREDENTIAL_BYTES {
eprintln!("owned credential file oversized, re-auth required: {}", path.display());
} Try / catch
match read_codewhale_owned_to_string(path) {
Ok(Some(contents)) => use_token(contents),
Ok(None) => reauthenticate(),
Err(e) if e.to_string().contains("exceeds") => { delete_and_reauth(path); }
Err(e) => return Err(e),
} Prevention
- Only Codewhale should write under its credentials directory; redirect other outputs elsewhere.
- Disable file-sync tools on the credentials directory to avoid conflict-copy bloat.
- On this error, delete the file and re-authenticate rather than trying to repair it in place.
When it happens
Trigger: Reading a Codewhale-owned credential file (e.g. a stored token or key file under Codewhale's credentials directory) whose byte length exceeds MAX_EXTERNAL_CREDENTIAL_BYTES — as exercised by owned_read_is_bounded and owned_read_is_bounded_on_windows.
Common situations: The credential file was corrupted or appended to repeatedly by a faulty writer; something else (a log, a bundle) was written at that basename; a sync tool merged conflicting versions into one large 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
- external credential file exceeds the byte safety limit
- bundle URLs may not include credentials
- Codewhale-owned credential file DACL is not…
- Codewhale-owned credential file DACL must grant only one…
- Codewhale-owned credential file must be singly linked
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/3862f358869afa9c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/external_credentials.rs:126
format!(
"securely opening Codewhale-owned credential file {}",
codewhale_config::quote_os_path(path)
)
});
}
};
let mut bytes = Vec::new();
file.by_ref()
.take(MAX_EXTERNAL_CREDENTIAL_BYTES + 1)
.read_to_end(&mut bytes)
.with_context(|| {
format!(
"reading Codewhale-owned credential file {}",
codewhale_config::quote_os_path(path)
)
})?;
if bytes.len() as u64 > MAX_EXTERNAL_CREDENTIAL_BYTES {
bail!(
"Codewhale-owned credential file {} exceeds the {} byte safety limit",
codewhale_config::quote_os_path(path),
MAX_EXTERNAL_CREDENTIAL_BYTES
);
}
String::from_utf8(bytes).map(Some).with_context(|| {
format!(
"Codewhale-owned credential file {} is not valid UTF-8",
codewhale_config::quote_os_path(path)
)
})
}
#[cfg(unix)]
fn open_secure_regular_file(path: &Path, require_owner_only: bool) -> io::Result<File> {
use std::ffi::CString;
use std::os::fd::FromRawFd;
use std::os::unix::ffi::OsStrExt;View on GitHub (pinned to 73e0f67d83)