{"record":{"id":"943b12aedc52f0f4","repo":"tinyhumansai/openhuman","slug":"key-must-be-an-array-of-strings","errorCode":null,"errorMessage":"`{key}` must be an array of strings","messagePattern":"`(.+?)` must be an array of strings","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/openhuman/agent/tools/todo.rs","lineNumber":295,"sourceCode":"        approval_mode,\n        acceptance_criteria: optional_string_array(args, \"acceptanceCriteria\")?,\n        evidence: optional_string_array(args, \"evidence\")?,\n        notes: optional_string(args, \"notes\"),\n        blocker: optional_string(args, \"blocker\"),\n        source_metadata: None,\n    })\n}\n\nfn optional_string_array(\n    args: &serde_json::Value,\n    key: &str,\n) -> anyhow::Result<Option<Vec<String>>> {\n    let Some(value) = args.get(key) else {\n        return Ok(None);\n    };\n    let values = value\n        .as_array()\n        .ok_or_else(|| anyhow::anyhow!(\"`{key}` must be an array of strings\"))?;\n    values\n        .iter()\n        .map(|item| {\n            item.as_str()\n                .map(|s| s.to_string())\n                .ok_or_else(|| anyhow::anyhow!(\"`{key}` must be an array of strings\"))\n        })\n        .collect::<anyhow::Result<Vec<_>>>()\n        .map(Some)\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use serde_json::Value;\n\n    /// Serialize tests that share the process-global scratch store with\n    /// `todos::ops` tests. Same lock — otherwise the two test modules race","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/agent/tools/todo.rs#L277-L313","documentation":"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.","triggerScenarios":"Thrown at src/openhuman/agent/tools/todo.rs:295 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply the named key as an array of strings, or omit it entirely","Ensure no element is a non-string JSON type"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}