tinyhumansai/openhuman · error · anyhow::Error

` ` must be an array of strings

Error message

`{key}` must be an array of strings

What it means

A todo-tool array argument (`acceptanceCriteria` or `evidence`, via optional_string_array) was present but its JSON value is not an array. The helper tolerates absence (returns None) and then requires every element to be a string; a non-array value fails at the as_array type check.

Solutions

  1. Supply the named key as an array of strings, or omit it entirely
  2. Ensure no element is a non-string JSON type
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/openhuman/agent/tools/todo.rs:295 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/943b12aedc52f0f4. Report an issue: GitHub.

Appendix: source

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

        approval_mode,
        acceptance_criteria: optional_string_array(args, "acceptanceCriteria")?,
        evidence: optional_string_array(args, "evidence")?,
        notes: optional_string(args, "notes"),
        blocker: optional_string(args, "blocker"),
        source_metadata: None,
    })
}

fn optional_string_array(
    args: &serde_json::Value,
    key: &str,
) -> anyhow::Result<Option<Vec<String>>> {
    let Some(value) = args.get(key) else {
        return Ok(None);
    };
    let values = value
        .as_array()
        .ok_or_else(|| anyhow::anyhow!("`{key}` must be an array of strings"))?;
    values
        .iter()
        .map(|item| {
            item.as_str()
                .map(|s| s.to_string())
                .ok_or_else(|| anyhow::anyhow!("`{key}` must be an array of strings"))
        })
        .collect::<anyhow::Result<Vec<_>>>()
        .map(Some)
}

#[cfg(test)]
mod tests {
    use super::*;
    use serde_json::Value;

    /// Serialize tests that share the process-global scratch store with
    /// `todos::ops` tests. Same lock — otherwise the two test modules race

View on GitHub (pinned to 7491200858)