{"record":{"id":"e600f0e3f10a0f67","repo":"Hmbown/CodeWhale","slug":"goal-snapshot-has-no-objective","errorCode":null,"errorMessage":"goal snapshot has no objective","messagePattern":"goal snapshot has no objective","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/session_manager.rs","lineNumber":776,"sourceCode":"\nconst fn current_session_goal_schema_version() -> u32 {\n    CURRENT_SESSION_GOAL_SCHEMA_VERSION\n}\n\nimpl SessionGoalState {\n    /// Convert a runtime update into the durable, bounded session contract.\n    /// The canonical empty runtime snapshot removes the sidecar.\n    pub fn from_runtime(snapshot: &GoalSnapshot) -> io::Result<Option<Self>> {\n        if snapshot.objective.is_none() && snapshot.status.trim() == \"none\" {\n            return Ok(None);\n        }\n        let objective = snapshot\n            .objective\n            .as_deref()\n            .map(str::trim)\n            .filter(|objective| !objective.is_empty())\n            .ok_or_else(|| {\n                io::Error::new(io::ErrorKind::InvalidData, \"goal snapshot has no objective\")\n            })?;\n        let status = match snapshot.status.trim() {\n            \"active\" => SessionGoalStatus::Active,\n            \"paused\" => SessionGoalStatus::Paused,\n            \"complete\" => SessionGoalStatus::Complete,\n            \"blocked\" => SessionGoalStatus::Blocked,\n            other => {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    format!(\"goal snapshot has unsupported status '{other}'\"),\n                ));\n            }\n        };\n        let state = Self {\n            schema_version: CURRENT_SESSION_GOAL_SCHEMA_VERSION,\n            objective: objective.to_string(),\n            status,\n            token_budget: snapshot.token_budget,","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/session_manager.rs#L758-L794","documentation":"When converting a persisted goal snapshot into session state, the objective field must exist and be non-empty after trimming. A snapshot whose objective is missing, whitespace-only, or empty cannot form a valid session goal, so InvalidData is thrown with this message.","triggerScenarios":"Loading a goal snapshot whose JSON lacks the objective field, has objective: null, or objective set to \"\" or only whitespace.","commonSituations":"Hand-edited or partially written goal files; older tooling that wrote goal snapshots without an objective; a crash during goal creation left an empty objective; schema drift between versions.","solutions":["Edit the goal snapshot file and set a non-empty objective string.","Delete the goal file so the session starts without a goal, then set a new goal in the TUI.","Recreate the goal through the interactive session instead of editing files by hand."],"exampleFix":"// before: sessions/goal.json\n{\"objective\": \"\", \"status\": \"active\", ...}\n// after\n{\"objective\": \"Ship the parser rewrite\", \"status\": \"active\", ...}","handlingStrategy":"validation","validationCode":"fn goal_objective_valid(snapshot: &GoalSnapshot) -> bool {\n    snapshot.objective.as_deref().map(str::trim).map_or(false, |o| !o.is_empty())\n}","typeGuard":"fn has_objective(s: &Option<String>) -> bool {\n    s.as_deref().map(|o| !o.trim().is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match load_goal(path) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData && e.to_string().contains(\"no objective\") => {\n        eprintln!(\"goal file lacks an objective; delete it and set a new goal\");\n    }\n    other => other?,\n}","preventionTips":["Never hand-edit goal files; use the TUI to set goals.","Ensure objective is non-empty when generating goal JSON.","Back up goal files before schema/version changes."],"tags":["validation","goals","io"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}