tinyhumansai/openhuman · error · anyhow::Error

invalid approvalMode

Error message

invalid approvalMode '{other}' (expected required|not_required|null)

What it means

The todo tool received an `approvalMode` whose string value is neither `required` nor `not_required`. Parsed inside patch_from_args while building a CardPatch; null is accepted as an explicit clear, so only unrecognized non-null strings reach this error.

Solutions

  1. Use "required", "not_required", or null for approvalMode
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/agent/tools/todo.rs:258 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/b8e8383e518fc89b. Report an issue: GitHub.

Appendix: source

Thrown at src/openhuman/agent/tools/todo.rs:258

fn optional_string(args: &serde_json::Value, key: &str) -> Option<String> {
    args.get(key)
        .and_then(|v| v.as_str())
        .map(|s| s.to_string())
}

fn patch_from_args(args: &serde_json::Value) -> anyhow::Result<CardPatch> {
    let status: Option<TaskCardStatus> = match args.get("status").and_then(|v| v.as_str()) {
        Some(s) => Some(ops::parse_status(s).map_err(anyhow::Error::msg)?),
        None => None,
    };
    let approval_mode = match args.get("approvalMode") {
        Some(value) if value.is_null() => Some(None),
        Some(value) => match value.as_str() {
            Some("required") => Some(Some(TaskApprovalMode::Required)),
            Some("not_required") => Some(Some(TaskApprovalMode::NotRequired)),
            Some(other) => {
                return Err(anyhow::anyhow!(
                    "invalid approvalMode '{other}' (expected required|not_required|null)"
                ))
            }
            None => {
                return Err(anyhow::anyhow!(
                    "invalid approvalMode type (expected required|not_required|null)"
                ))
            }
        },
        None => None,
    };
    Ok(CardPatch {
        content: None,
        status,
        objective: optional_string(args, "objective"),
        plan: optional_string_array(args, "plan")?,
        assigned_agent: optional_string(args, "assignedAgent"),
        allowed_tools: optional_string_array(args, "allowedTools")?,

View on GitHub (pinned to 7491200858)