{"record":{"id":"61889faf878ee866","repo":"unicity-aos/aos-ce","slug":"hook-adapter-oracle-dropping-context-beyond-max-host-context","errorCode":null,"errorMessage":"hook-adapter-oracle: dropping context beyond {MAX_HOST_CONTEXT_BYTES} bytes","messagePattern":"hook-adapter-oracle: dropping context beyond (.+?) bytes","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"capsules/capsule-hook-adapter-oracle/src/lib.rs","lineNumber":293,"sourceCode":"                }\n                for message in poll.messages {\n                    if message.topic != reply_topic\n                        || message.principal.verified() != Some(principal)\n                    {\n                        log::warn(format!(\n                            \"hook-adapter-oracle: dropping mismatched context reply on {reply_topic}\"\n                        ));\n                        continue;\n                    }\n                    match serde_json::from_str::<serde_json::Value>(&message.payload) {\n                        Ok(value) => {\n                            if let Some(context) = value\n                                .get(\"additional_context\")\n                                .and_then(serde_json::Value::as_str)\n                                .filter(|context| !context.trim().is_empty())\n                                && !push_context(&mut contexts, &mut context_bytes, context)\n                            {\n                                log::warn(format!(\n                                    \"hook-adapter-oracle: dropping context beyond {MAX_HOST_CONTEXT_BYTES} bytes\"\n                                ));\n                            }\n                        }\n                        Err(error) => log::warn(format!(\n                            \"hook-adapter-oracle: dropping malformed reply on {reply_topic}: {error}\"\n                        )),\n                    }\n                }\n            }\n            Err(SysError::HostError(message)) if message.contains(\"Timeout\") => break,\n            Err(error) => return Err(error),\n        }\n    }\n    if contexts.is_empty() {\n        Ok(None)\n    } else {\n        Ok(Some(contexts.join(\"\\n\\n\")))","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/capsules/capsule-hook-adapter-oracle/src/lib.rs#L275-L311","documentation":"The oracle hook adapter caps the total size of additional context forwarded to the hook at MAX_HOST_CONTEXT_BYTES. When a hook reply contains an additional_context string that would push the accumulated context over that cap, push_context refuses it and the adapter logs this warning and silently drops that context entry. This is a protective limit to bound host memory/payload size, not a hard failure — processing continues with truncated context.","triggerScenarios":"Occurs in collect_additional_context (invoked from dispatch_oracle_hook) when parsing hook replies: a reply's 'additional_context' field is a non-empty string but the cumulative context_bytes already accumulated plus this context's size exceeds MAX_HOST_CONTEXT_BYTES, so push_context returns false.","commonSituations":"Developers attaching large blobs (logs, file dumps, large JSON payloads) as additional_context in oracle hook replies; multiple hook replies each adding context until the aggregate cap is hit; underestimating the byte budget when several capsules contribute context to one hook dispatch.","solutions":["Reduce the size of the additional_context payload in the hook reply (truncate or summarize before returning it).","Raise MAX_HOST_CONTEXT_BYTES in capsule-hook-adapter-oracle if the cap is genuinely too small for your workload and host limits allow.","Send only the most relevant context: filter or rank context entries in the hook implementation so the important ones are pushed first.","Check earlier log lines to see which reply/topic contributed the oversized context and fix that producer."],"exampleFix":"// before\nlet context = build_full_debug_dump(); // multi-MB string\nreply.additional_context = Some(context);\n// after\nlet context = build_full_debug_dump();\nreply.additional_context = Some(truncate_to_bytes(&context, MAX_HOST_CONTEXT_BYTES / 4));","handlingStrategy":"validation","validationCode":"// Rust (hook reply producer)\nconst MAX_HOST_CONTEXT_BYTES: usize = 8 * 1024;\nfn context_fits(current_bytes: usize, next: &str) -> bool {\n    current_bytes + next.len() <= MAX_HOST_CONTEXT_BYTES\n}\nassert!(context_fits(acc_bytes, &context), \"additional_context would exceed byte cap\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Truncate or summarize large context payloads before attaching them to hook replies.","Budget context bytes across all capsules contributing to one hook dispatch.","Monitor for this warning in logs; repeated occurrences indicate producers need smaller payloads."],"tags":["rust","size-limit","payload-truncation"],"backgroundTag":"payload-too-large","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"}