Hmbown/CodeWhale · error · InvalidData
Session goal is bytes; maximum is
Error message
Session goal {} is {file_len} bytes; maximum is {MAX_SESSION_GOAL_FILE_BYTES} What it means
Session goal files are capped at MAX_SESSION_GOAL_FILE_BYTES (64 KiB). If the goal file on disk exceeds that bound, loading is aborted with InvalidData naming the path, its actual size, and the maximum, preventing unbounded file reads from entering session state. A prior integrity check (checked_existing_session_goal_file) must also pass before this size gate runs.
Solutions
- Trim the goal file to under 64 KiB (keep a concise goal summary, move details elsewhere)
- Delete or rename the oversized file and write a fresh, short goal statement
- Point the session at a different goal file within the size limit
Example fix
# before wc -c session-goal.md # 200000 bytes # after head -c 65000 session-goal.md > tmp && mv tmp session-goal.md
Defensive patterns
Strategy: validation
Validate before calling
fn goal_file_ok(path: &Path) -> bool {
std::fs::metadata(path).map(|m| m.len() <= 64*1024).unwrap_or(false)
} Try / catch
match manager.load_session(&sid) {
Err(e) if e.kind() == io::ErrorKind::InvalidData
&& e.to_string().contains("maximum is 65536") => {
// prompt user to shrink the goal file, then retry
}
other => other,
} Prevention
- Keep goal files concise; store large docs elsewhere and reference them
- Enforce the 64 KiB limit in any tooling that writes goal files
- Check file size after external edits to goal files
When it happens
Trigger: Reading an existing session goal file whose fs::metadata length is greater than 64 KiB — an externally edited or oversized goal file.
Common situations: Pasting a very large document into the goal file by hand; scripts appending to the goal file; wrong file placed at the goal path (e.g. a log or dataset).
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
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/f30bc517c7a68903.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/session_manager.rs:1740
self.ensure_session_goals_dir()?;
Self::checked_existing_session_goal_file(&path)?;
let content = serde_json::to_string_pretty(goal)
.map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))?;
write_atomic(&path, content.as_bytes())
}
/// Load a saved session's durable goal, rejecting malformed or future
/// records instead of silently starting a different objective.
pub fn load_session_goal(&self, session_id: &str) -> std::io::Result<Option<SessionGoalState>> {
let path = self.validated_session_goal_path(session_id)?;
if self.checked_existing_session_goals_dir()?.is_none()
|| !Self::checked_existing_session_goal_file(&path)?
{
return Ok(None);
}
let file_len = fs::metadata(&path)?.len();
if file_len > MAX_SESSION_GOAL_FILE_BYTES {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
format!(
"Session goal {} is {file_len} bytes; maximum is {MAX_SESSION_GOAL_FILE_BYTES}",
path.display()
),
));
}
let raw = fs::read_to_string(path)?;
let goal: SessionGoalState = serde_json::from_str(&raw)
.map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))?;
goal.validate()?;
Ok(Some(goal))
}
fn hydrate_recovered_runtime_binding(&self, session: &mut SavedSession) -> std::io::Result<()> {
// Compare under the session write lock. A stale process may neither
// resurrect a missing binding nor replace a different recovered owner.
if let Some(incoming) = session.metadata.runtime_store.as_ref()View on GitHub (pinned to 433685b202)