unicity-aos/aos-ce · warning
meta-harness: malformed hook request
Error message
meta-harness: malformed hook request: {error} What it means
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.
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.
Example fix
// before
pub fn on_message_received(&self, payload: serde_json::Value) -> Result<(), SysError> {
let request: HookRequest = serde_json::from_value(payload)?; // mismatch on shape
// after
pub fn on_message_received(&self, payload: serde_json::Value) -> Result<(), SysError> {
// align payload with HookRequest: { "correlation_id": "...", "payload": "..." }
let request: HookRequest = serde_json::from_value(payload)?; Defensive patterns
Strategy: validation
Validate before calling
function isValidHookRequest(payload) {
return typeof payload === 'object' && payload !== null &&
typeof payload.correlation_id === 'string' &&
typeof payload.payload === 'string';
} Type guard
fn is_hook_request(v: &serde_json::Value) -> bool {
v.get("correlation_id").map_or(false, |c| c.is_string())
&& v.get("payload").map_or(false, |p| p.is_string())
} Try / catch
let request: HookRequest = match serde_json::from_value(payload) {
Ok(r) => r,
Err(e) => { log::warn("malformed hook request: {e}"); return Ok(()); }
}; Prevention
- Keep HookRequest struct in sync with the host interceptor schema
- Validate interceptor payloads in integration tests
- Pin host and capsule versions together
When it happens
Trigger: 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.
Common situations: Host version emitting a changed interceptor payload schema; another interceptor or plugin forwarding the wrong payload; hand-crafted test payloads missing fields.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- meta-harness: malformed canonical payload
- Failed to parse from prompt builder
- failed to deserialize IPC message payload
- failed to deserialize compaction response payload
- canonical document exceeds bound
AI-assisted analysis of unicity-aos/aos-ce@f6f22024fb (2026-09-13).
Data as JSON: /api/errors/865f78ce75a353d4.
Report an issue: GitHub.
Appendix: source
Thrown at capsules/capsule-meta-harness/src/lib.rs:65
"off" => Ok(None),
other => {
log::warn(format!(
"meta-harness: unknown activation mode '{other}', using adaptive"
));
Ok(Some(ADAPTIVE_CONTEXT))
}
}
}
#[capsule]
impl MetaHarness {
/// Add private same-turn reflection context to an exact host prompt turn.
#[astrid::interceptor("on_message_received")]
pub fn on_message_received(&self, payload: serde_json::Value) -> Result<(), SysError> {
let request: HookRequest = match serde_json::from_value(payload) {
Ok(request) => request,
Err(error) => {
log::warn(format!("meta-harness: malformed hook request: {error}"));
return Ok(());
}
};
let Some(correlation_id) = request.correlation_id else {
return Ok(());
};
if !is_correlation(&correlation_id) {
log::warn("meta-harness: ignored unroutable hook correlation");
return Ok(());
}
let canonical: CanonicalHostPayload = match serde_json::from_str(&request.payload) {
Ok(canonical) => canonical,
Err(error) => {
log::warn(format!(
"meta-harness: malformed canonical payload: {error}"
));
return Ok(());
}View on GitHub (pinned to f6f22024fb)