{"record":{"id":"a337556a4df986cb","repo":"Hmbown/CodeWhale","slug":"hunt-verdict-task-update-must-be-a-string","errorCode":null,"errorMessage":"hunt_verdict task update must be a string","messagePattern":"hunt_verdict task update must be a string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/task_manager.rs","lineNumber":2852,"sourceCode":"                .context(\"Failed to parse gate task update\")?;\n            let summary = format!(\"Gate {} {}: {}\", gate.gate, gate.status, gate.summary);\n            task.gates.retain(|existing| existing.id != gate.id);\n            task.gates.push(gate.clone());\n            push_timeline_entry(\n                task,\n                TaskTimelineEntry {\n                    timestamp: now,\n                    kind: \"gate\".to_string(),\n                    summary: summarize_text(&summary, TIMELINE_SUMMARY_LIMIT),\n                    detail_path: gate.log_path,\n                },\n            );\n        }\n\n        if let Some(value) = updates.get(\"hunt_verdict\") {\n            let raw = value\n                .as_str()\n                .ok_or_else(|| anyhow!(\"hunt_verdict task update must be a string\"))?;\n            let verdict = normalize_hunt_verdict(raw)?;\n            if task.hunt_verdict.as_deref() != Some(verdict) {\n                task.hunt_verdict = Some(verdict.to_string());\n                push_timeline_entry(\n                    task,\n                    TaskTimelineEntry {\n                        timestamp: now,\n                        kind: \"hunt_verdict\".to_string(),\n                        summary: format!(\"Hunt verdict updated: {verdict}\"),\n                        detail_path: None,\n                    },\n                );\n            }\n        }\n\n        if let Some(value) = updates.get(\"attempt\") {\n            let attempt: TaskAttemptRecord = serde_json::from_value(value.clone())\n                .context(\"Failed to parse attempt task update\")?;","sourceCodeStart":2834,"sourceCodeEnd":2870,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/task_manager.rs#L2834-L2870","documentation":"apply of task updates reads updates[\"hunt_verdict\"] and requires it to be a JSON string via value.as_str(); any non-string (number, bool, null, object) throws this error. The value is then normalized with normalize_hunt_verdict, so it must also be a recognizable verdict string.","triggerScenarios":"Sending a task-update map where hunt_verdict is not a JSON string, e.g. hunt_verdict: 1, true, null, or a nested object; or an unnormalized verdict string that normalize_hunt_verdict rejects on the next line.","commonSituations":"Agent/tool callers building the update map programmatically and inserting an enum as a number; JSON payloads produced by a schema-less path; typos in verdict names after the type check passes.","solutions":["Coerce the verdict to a string before putting it in the updates map: value.to_string() or format it explicitly.","Send one of the recognized verdict strings accepted by normalize_hunt_verdict.","Validate/skip the key when the value is not a string instead of including it in updates."],"exampleFix":"// before\njson!({\"hunt_verdict\": 1})\n// after\njson!({\"hunt_verdict\": \"confirmed\"})","handlingStrategy":"type-guard","validationCode":"if let Some(v) = updates.get(\"hunt_verdict\") {\n    if !v.is_string() { return Err(anyhow!(\"hunt_verdict must be a string\")); }\n}","typeGuard":"fn is_string_verdict(v: &serde_json::Value) -> bool { v.is_string() }","tryCatchPattern":null,"preventionTips":["Always serialize verdict enums with .to_string()/serde before inserting into the update map.","Use a typed struct for updates instead of raw JSON maps.","Validate verdict strings against the accepted set before sending."],"tags":["rust","type-mismatch","json"],"backgroundTag":"type-mismatch","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}