{"record":{"id":"966f1b2053a17aa9","repo":"tinyhumansai/openhuman","slug":"invalid-approvalmode-type-expected-required-not-r","errorCode":null,"errorMessage":"invalid approvalMode type (expected required|not_required|null)","messagePattern":"invalid approvalMode type \\(expected required\\|not_required\\|null\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/openhuman/agent/tools/todo.rs","lineNumber":263,"sourceCode":"}\n\nfn patch_from_args(args: &serde_json::Value) -> anyhow::Result<CardPatch> {\n    let status: Option<TaskCardStatus> = match args.get(\"status\").and_then(|v| v.as_str()) {\n        Some(s) => Some(ops::parse_status(s).map_err(anyhow::Error::msg)?),\n        None => None,\n    };\n    let approval_mode = match args.get(\"approvalMode\") {\n        Some(value) if value.is_null() => Some(None),\n        Some(value) => match value.as_str() {\n            Some(\"required\") => Some(Some(TaskApprovalMode::Required)),\n            Some(\"not_required\") => Some(Some(TaskApprovalMode::NotRequired)),\n            Some(other) => {\n                return Err(anyhow::anyhow!(\n                    \"invalid approvalMode '{other}' (expected required|not_required|null)\"\n                ))\n            }\n            None => {\n                return Err(anyhow::anyhow!(\n                    \"invalid approvalMode type (expected required|not_required|null)\"\n                ))\n            }\n        },\n        None => None,\n    };\n    Ok(CardPatch {\n        content: None,\n        status,\n        objective: optional_string(args, \"objective\"),\n        plan: optional_string_array(args, \"plan\")?,\n        assigned_agent: optional_string(args, \"assignedAgent\"),\n        allowed_tools: optional_string_array(args, \"allowedTools\")?,\n        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\"),","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/src/openhuman/agent/tools/todo.rs#L245-L281","documentation":"CardPatch parsing: args[\"approvalMode\"] is present, is not null, and is not a string (todo.rs:263) — e.g. true, 1, an array, or an object. The accepted shapes are exactly the strings \"required\"/\"not_required\" or JSON null; anything else fails with this type error before value validation even starts.","triggerScenarios":"Passing a boolean (approvalMode: true), a number, or a nested config object; serializers that map tri-state enums to booleans instead of string|null.","commonSituations":"Client models with a boolean approval flag; models inventing structured payloads for a scalar field.","solutions":["Send approvalMode as a string (\"required\"/\"not_required\") or null — never a boolean or object","In wrappers, map boolean tri-state (true/false/absent) to the string/null literals explicitly","Omit the field entirely when no override is needed"],"exampleFix":"// before\n{ \"op\": \"edit\", \"id\": \"t1\", \"approvalMode\": true }\n\n// after\n{ \"op\": \"edit\", \"id\": \"t1\", \"approvalMode\": \"required\" }","handlingStrategy":"type-guard","validationCode":"const a = args as Record<string, unknown>;\nif (a?.approvalMode !== undefined && a.approvalMode !== null\n    && typeof a.approvalMode !== \"string\") {\n  throw new Error(\"approvalMode must be a string or null, not \" + typeof a.approvalMode);\n}","typeGuard":"function isApprovalModeValue(v: unknown): v is string | null {\n  return v === null || typeof v === \"string\";\n}","tryCatchPattern":"if e.to_string().contains(\"invalid approvalMode type\") {\n    return Ok(ToolResult::error(\"approvalMode must be the string 'required'/'not_required' or null — booleans/objects are rejected\"));\n}","preventionTips":["Never serialize approvalMode as a boolean or object — it is string|null on the wire","Map boolean tri-state flags to the string literals explicitly in client code","Omit the field when no override change is intended"],"tags":["rust","tool","arguments","llm","todo"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}