{"record":{"id":"865f78ce75a353d4","repo":"unicity-aos/aos-ce","slug":"meta-harness-malformed-hook-request-error","errorCode":null,"errorMessage":"meta-harness: malformed hook request: {error}","messagePattern":"meta-harness: malformed hook request: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"capsules/capsule-meta-harness/src/lib.rs","lineNumber":65,"sourceCode":"        \"off\" => Ok(None),\n        other => {\n            log::warn(format!(\n                \"meta-harness: unknown activation mode '{other}', using adaptive\"\n            ));\n            Ok(Some(ADAPTIVE_CONTEXT))\n        }\n    }\n}\n\n#[capsule]\nimpl MetaHarness {\n    /// Add private same-turn reflection context to an exact host prompt turn.\n    #[astrid::interceptor(\"on_message_received\")]\n    pub fn on_message_received(&self, payload: serde_json::Value) -> Result<(), SysError> {\n        let request: HookRequest = match serde_json::from_value(payload) {\n            Ok(request) => request,\n            Err(error) => {\n                log::warn(format!(\"meta-harness: malformed hook request: {error}\"));\n                return Ok(());\n            }\n        };\n        let Some(correlation_id) = request.correlation_id else {\n            return Ok(());\n        };\n        if !is_correlation(&correlation_id) {\n            log::warn(\"meta-harness: ignored unroutable hook correlation\");\n            return Ok(());\n        }\n        let canonical: CanonicalHostPayload = match serde_json::from_str(&request.payload) {\n            Ok(canonical) => canonical,\n            Err(error) => {\n                log::warn(format!(\n                    \"meta-harness: malformed canonical payload: {error}\"\n                ));\n                return Ok(());\n            }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/capsules/capsule-meta-harness/src/lib.rs#L47-L83","documentation":"The meta-harness capsule's on_message_received interceptor expects a JSON payload deserializable into HookRequest. If serde_json::from_value fails, the hook request is malformed; the capsule logs this warning and returns Ok(()) (swallowing the error) so the host turn proceeds without reflection context.","triggerScenarios":"on_message_received is invoked with a payload that is not valid JSON for HookRequest — missing required fields, wrong types (e.g., correlation_id not a string), or a completely different payload shape from the interceptor dispatcher.","commonSituations":"Host version emitting a changed interceptor payload schema; another interceptor or plugin forwarding the wrong payload; hand-crafted test payloads missing fields.","solutions":["Log/inspect the raw payload and compare it to the HookRequest struct fields; fix the producer to emit the expected shape.","Update the HookRequest struct (serde attributes, Option fields) to match the current host payload schema.","Ensure capsule and host versions are aligned so the interceptor contract matches.","If the payload is user-supplied, validate it before registering the interceptor."],"exampleFix":"// before\npub fn on_message_received(&self, payload: serde_json::Value) -> Result<(), SysError> {\n    let request: HookRequest = serde_json::from_value(payload)?; // mismatch on shape\n// after\npub fn on_message_received(&self, payload: serde_json::Value) -> Result<(), SysError> {\n    // align payload with HookRequest: { \"correlation_id\": \"...\", \"payload\": \"...\" }\n    let request: HookRequest = serde_json::from_value(payload)?;","handlingStrategy":"validation","validationCode":"function isValidHookRequest(payload) {\n  return typeof payload === 'object' && payload !== null &&\n    typeof payload.correlation_id === 'string' &&\n    typeof payload.payload === 'string';\n}","typeGuard":"fn is_hook_request(v: &serde_json::Value) -> bool {\n    v.get(\"correlation_id\").map_or(false, |c| c.is_string())\n        && v.get(\"payload\").map_or(false, |p| p.is_string())\n}","tryCatchPattern":"let request: HookRequest = match serde_json::from_value(payload) {\n    Ok(r) => r,\n    Err(e) => { log::warn(\"malformed hook request: {e}\"); return Ok(()); }\n};","preventionTips":["Keep HookRequest struct in sync with the host interceptor schema","Validate interceptor payloads in integration tests","Pin host and capsule versions together"],"tags":["json","deserialization","interceptor","schema"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"f6f22024fb1e8d122f28a1b4a9f75aee448ae839","analyzedAt":"2026-09-13T03:04:44.565Z","contentChangedAt":"2026-09-13T03:04:44.565Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}