Hmbown/CodeWhale · error

hunt_verdict task update must be a string

Error message

hunt_verdict task update must be a string

What it means

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.

Solutions

  1. Coerce the verdict to a string before putting it in the updates map: value.to_string() or format it explicitly.
  2. Send one of the recognized verdict strings accepted by normalize_hunt_verdict.
  3. Validate/skip the key when the value is not a string instead of including it in updates.

Example fix

// before
json!({"hunt_verdict": 1})
// after
json!({"hunt_verdict": "confirmed"})
Defensive patterns

Strategy: type-guard

Validate before calling

if let Some(v) = updates.get("hunt_verdict") {
    if !v.is_string() { return Err(anyhow!("hunt_verdict must be a string")); }
}

Type guard

fn is_string_verdict(v: &serde_json::Value) -> bool { v.is_string() }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/a337556a4df986cb. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/task_manager.rs:2852

                .context("Failed to parse gate task update")?;
            let summary = format!("Gate {} {}: {}", gate.gate, gate.status, gate.summary);
            task.gates.retain(|existing| existing.id != gate.id);
            task.gates.push(gate.clone());
            push_timeline_entry(
                task,
                TaskTimelineEntry {
                    timestamp: now,
                    kind: "gate".to_string(),
                    summary: summarize_text(&summary, TIMELINE_SUMMARY_LIMIT),
                    detail_path: gate.log_path,
                },
            );
        }

        if let Some(value) = updates.get("hunt_verdict") {
            let raw = value
                .as_str()
                .ok_or_else(|| anyhow!("hunt_verdict task update must be a string"))?;
            let verdict = normalize_hunt_verdict(raw)?;
            if task.hunt_verdict.as_deref() != Some(verdict) {
                task.hunt_verdict = Some(verdict.to_string());
                push_timeline_entry(
                    task,
                    TaskTimelineEntry {
                        timestamp: now,
                        kind: "hunt_verdict".to_string(),
                        summary: format!("Hunt verdict updated: {verdict}"),
                        detail_path: None,
                    },
                );
            }
        }

        if let Some(value) = updates.get("attempt") {
            let attempt: TaskAttemptRecord = serde_json::from_value(value.clone())
                .context("Failed to parse attempt task update")?;

View on GitHub (pinned to 433685b202)