Hmbown/CodeWhale · error

unsupported hunt_verdict task update

Error message

unsupported hunt_verdict task update '{other}'. Expected one of: hunting, hunted, wounded, escaped

What it means

normalize_hunt_verdict validates the hunt_verdict task update field against the closed set {hunting, hunted, wounded, escaped} (whitespace-trimmed). Any other string is rejected with the full allowed list in the message.

Solutions

  1. Use exactly one of: hunting, hunted, wounded, escaped (trimmed)
  2. Normalize casing and trim the incoming verdict before sending
  3. Map legacy verdict names to the supported set at the producer

Example fix

// before
update(\"task_abc...\", TaskUpdate { hunt_verdict: Some("Hunted".into()) });
// after
let verdict = raw.trim().to_lowercase();
anyhow::ensure!(matches!(verdict.as_str(), "hunting"|"hunted"|"wounded"|"escaped"), "bad verdict {verdict}");
update(\"task_abc...\", TaskUpdate { hunt_verdict: Some(verdict) });
Defensive patterns

Strategy: validation

Validate before calling

const VERDICTS: [&str; 4] = ["hunting", "hunted", "wounded", "escaped"];
if !VERDICTS.contains(&raw.trim()) {
    return Err(format!("bad hunt_verdict: {raw}"));
}

Type guard

fn is_hunt_verdict(s: &str) -> Option<&'static str> {
    ["hunting","hunted","wounded","escaped"].into_iter().find(|v| *v == s.trim())
}

Try / catch

match normalize_hunt_verdict(raw) {
    Ok(v) => apply(v),
    Err(e) => { /* surface allowed values to the caller/UI */ }
}

Prevention

When it happens

Trigger: Submitting a task update with hunt_verdict set to an unrecognized value — e.g. "Hunted" (wrong case), "hunt", "kill", "", or a typo — through the hunt-verdict update path.

Common situations: UI/automation sending verdicts in different casing or from an older vocabulary; hand-written scripts or tests using invented verdict names; schema drift between a producer and this validator.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

            &QueueFile {
                queue: queue.iter().cloned().collect(),
            },
        )
    }

    fn persist_task_locked(&self, task: &TaskRecord) -> Result<()> {
        let path = self.tasks_dir.join(format!("{}.json", task.id));
        write_json_atomic(&path, task)
    }
}

fn normalize_hunt_verdict(raw: &str) -> Result<&'static str> {
    match raw.trim() {
        "hunting" => Ok("hunting"),
        "hunted" => Ok("hunted"),
        "wounded" => Ok("wounded"),
        "escaped" => Ok("escaped"),
        other => bail!(
            "unsupported hunt_verdict task update '{other}'. Expected one of: hunting, hunted, wounded, escaped"
        ),
    }
}

fn validate_preallocated_task_id(task_id: &str) -> Result<()> {
    if task_id.len() != 21
        || !task_id.starts_with("task_")
        || !task_id[5..].chars().all(|ch| ch.is_ascii_hexdigit())
    {
        bail!("Invalid preallocated task id: expected task_<16hex>");
    }
    Ok(())
}

fn read_bound_task_file(path: &Path, task_id: &str) -> Result<Option<TaskRecord>> {
    let bytes = match fs::read(path) {
        Ok(bytes) => bytes,

View on GitHub (pinned to 433685b202)