{"record":{"id":"f30bc517c7a68903","repo":"Hmbown/CodeWhale","slug":"session-goal-is-file-len-bytes-maximum-is-m","errorCode":null,"errorMessage":"Session goal {} is {file_len} bytes; maximum is {MAX_SESSION_GOAL_FILE_BYTES}","messagePattern":"Session goal (.+?) is (.+?) bytes; maximum is (.+?)","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/session_manager.rs","lineNumber":1071,"sourceCode":"        self.ensure_session_goals_dir()?;\n        Self::checked_existing_session_goal_file(&path)?;\n        let content = serde_json::to_string_pretty(goal)\n            .map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))?;\n        write_atomic(&path, content.as_bytes())\n    }\n\n    /// Load a saved session's durable goal, rejecting malformed or future\n    /// records instead of silently starting a different objective.\n    pub fn load_session_goal(&self, session_id: &str) -> std::io::Result<Option<SessionGoalState>> {\n        let path = self.validated_session_goal_path(session_id)?;\n        if self.checked_existing_session_goals_dir()?.is_none()\n            || !Self::checked_existing_session_goal_file(&path)?\n        {\n            return Ok(None);\n        }\n        let file_len = fs::metadata(&path)?.len();\n        if file_len > MAX_SESSION_GOAL_FILE_BYTES {\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidData,\n                format!(\n                    \"Session goal {} is {file_len} bytes; maximum is {MAX_SESSION_GOAL_FILE_BYTES}\",\n                    path.display()\n                ),\n            ));\n        }\n        let raw = fs::read_to_string(path)?;\n        let goal: SessionGoalState = serde_json::from_str(&raw)\n            .map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))?;\n        goal.validate()?;\n        Ok(Some(goal))\n    }\n\n    /// Save a session to disk using atomic write (temp file + fsync + rename).\n    pub fn save_session(&self, session: &SavedSession) -> std::io::Result<PathBuf> {\n        let path = self.validated_session_path(&session.metadata.id)?;\n        let already_persisted = path.exists()","sourceCodeStart":1053,"sourceCodeEnd":1089,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/session_manager.rs#L1053-L1089","documentation":"The serialized session-goal file written to the session goals directory exceeds MAX_SESSION_GOAL_FILE_BYTES. The write path enforces a size ceiling so a pathologically large goal payload cannot bloat the sessions directory or slow startup; firing means the caller supplied an oversized goal object.","triggerScenarios":"Thrown at crates/tui/src/session_manager.rs:1071 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the size of the SessionGoalState payload before saving","Raise MAX_SESSION_GOAL_FILE_BYTES only if goals legitimately need more space","Reject or truncate oversized goals at the UI/editor layer before persisting"],"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-14T00:17:10.932Z"}