{"record":{"id":"0d2097fa3e03303d","repo":"tinyhumansai/openhuman","slug":"failed-to-serialize-action-response-e","errorCode":null,"errorMessage":"failed to serialize {action} response: {e}","messagePattern":"failed to serialize (.+?) response: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/openhuman/tinyplace/agent_tools/common.rs","lineNumber":381,"sourceCode":"pub fn sdk_error(action: &str, err: tinyplace::Error) -> ToolResult {\n    err_md(sdk_error_text(action, err))\n}\n\n/// Convenience: turn an SDK `Result` into `anyhow::Result<Value>`, rendering\n/// the error as markdown carried in the `anyhow` message (the FlowTool surfaces\n/// it to the LLM verbatim).\n///\n/// Serialization errors are **propagated**, not hidden: a response that fails to\n/// deserialize is a real bug worth surfacing. Callers hitting endpoints that\n/// return `null` for an *empty* collection should use [`list_or_empty`] instead,\n/// which degrades only that specific case.\npub fn val_or_err<T: serde::Serialize>(\n    action: &str,\n    result: tinyplace::Result<T>,\n) -> anyhow::Result<Value> {\n    match result {\n        Ok(v) => serde_json::to_value(v)\n            .map_err(|e| anyhow::anyhow!(\"failed to serialize {action} response: {e}\")),\n        Err(e) => Err(anyhow::anyhow!(\"{}\", sdk_error_text(action, e))),\n    }\n}\n\n/// Like [`val_or_err`], but for the narrow set of SDK calls whose backend\n/// returns `null` for an empty collection (`{\"messages\": null}`, empty\n/// submissions) — which the typed SDK surfaces as a `Serialization` error.\n/// Degrades **only** that case to an empty array; every other error, including a\n/// genuine shape mismatch, is still surfaced. Mirrors the `*_degrade` handling\n/// in the internal controllers, scoped to the endpoints that actually need it.\npub fn list_or_empty<T: serde::Serialize>(\n    action: &str,\n    result: tinyplace::Result<T>,\n) -> anyhow::Result<Value> {\n    match result {\n        Ok(v) => serde_json::to_value(v)\n            .map_err(|e| anyhow::anyhow!(\"failed to serialize {action} response: {e}\")),\n        Err(e) if is_empty_state(&e) => Ok(Value::Array(Vec::new())),","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/tinyplace/agent_tools/common.rs#L363-L399","documentation":"Wrapped error in the tiny.place tool result helpers: an SDK response succeeded but could not be serialized (serde_json) for return to the LLM. Per the helper's docs this is propagated rather than hidden — a response that fails to serialize is a real bug or an unexpected wire shape.","triggerScenarios":"Thrown at src/openhuman/tinyplace/agent_tools/common.rs:381 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check {e} for the serde detail naming the unserializable field","Compare the SDK response type against its serde attributes","Report as a bug if the SDK type genuinely cannot serialize"],"exampleFix":null,"handlingStrategy":"try-catch","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-14T05:17:10.506Z"}