{"record":{"id":"b07f4844efeff438","repo":"unicity-aos/aos-ce","slug":"hook-adapter-oracle-dropping-invalid-expected-name-hook","errorCode":null,"errorMessage":"hook-adapter-oracle: dropping invalid {expected.name()} hook '{event.event}': {reason}","messagePattern":"hook-adapter-oracle: dropping invalid (.+?) hook '(.+?)': (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"capsules/capsule-hook-adapter-oracle/src/lib.rs","lineNumber":373,"sourceCode":"    ipc::publish_json(&event_topic, &request)?;\n    collect_additional_context(&subscription, &reply_topic, &event.principal_id)\n}\n\nfn handle_oracle_hook(expected: Frontend, payload: serde_json::Value) -> Result<(), SysError> {\n    let event: OracleHookEvent = match serde_json::from_value(payload) {\n        Ok(event) => event,\n        Err(error) => {\n            log::warn(format!(\n                \"hook-adapter-oracle: dropping malformed {} hook: {error}\",\n                expected.name()\n            ));\n            return Ok(());\n        }\n    };\n    let mapping = match validate_oracle_hook(expected, &event) {\n        Ok(mapping) => mapping,\n        Err(reason) => {\n            log::warn(format!(\n                \"hook-adapter-oracle: dropping invalid {} hook '{}': {reason}\",\n                expected.name(),\n                event.event\n            ));\n            return Ok(());\n        }\n    };\n    let caller = runtime::caller()?;\n    if caller.principal.as_deref() != Some(event.principal_id.as_str()) {\n        log::warn(format!(\n            \"hook-adapter-oracle: dropping principal mismatch for {}\",\n            expected.name()\n        ));\n        return Ok(());\n    }\n\n    let context = dispatch_oracle_hook(&event, mapping)?;\n    ipc::publish_json(","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/capsules/capsule-hook-adapter-oracle/src/lib.rs#L355-L391","documentation":"handle_oracle_hook validates each incoming hook event against the expected hook type via validate_oracle_hook, which returns a reason on failure (wrong event name, missing/invalid fields for that hook's schema). If validation fails, the event is dropped with this warning and Ok(()) is returned — the hook is a no-op rather than a panic or trap.","triggerScenarios":"Raised in handle_oracle_hook (called from on_codex_hook, on_claude_hook, on_grok_hook) whenever validate_oracle_hook(expected, &event) returns Err: the event's 'event' field doesn't match the expected hook name, or required payload fields for that hook type are missing or malformed.","commonSituations":"A hook producer sends an event name that doesn't match the registered handler (typo, renamed hook after a version upgrade); a CLI/tool emits a hook payload schema the adapter doesn't recognize; wiring the same adapter to multiple hook entry points and sending the event to the wrong one.","solutions":["Inspect the warning's {reason} and {event.event} fields to see exactly which validation failed and fix the emitted hook payload.","Verify the hook name registered in the tool config (codex/claude/grok settings) matches what the adapter's on_*_hook expects.","Update the adapter or the producer so their hook schemas agree after any version upgrade.","Test the hook payload with a minimal known-good example to isolate schema mismatch."],"exampleFix":"// before (tool hook config)\n{ \"event\": \"oracle_query\", \"command\": \"capsule invoke ...\" }\n// after (match expected.name())\n{ \"event\": \"codex_oracle_query\", \"command\": \"capsule invoke ...\" }","handlingStrategy":"validation","validationCode":"// Validate the hook payload before emitting it\nfn valid_hook(event: &HookEvent, expected: &ExpectedHook) -> Result<(), String> {\n    if event.event != expected.name() { return Err(format!(\"event '{}' != '{}'\", event.event, expected.name())); }\n    if event.payload.is_empty() { return Err(\"payload is empty\".into()); }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"// Adapter already returns Ok(()) on invalid hooks; treat a logged drop as a no-op and re-dispatch a corrected event\nif let Err(reason) = validate_oracle_hook(expected, &event) {\n    eprintln!(\"hook rejected: {reason}; fix payload and resend\");\n}","preventionTips":["Keep the hook event name in tool config in sync with the adapter's expected hook name.","Validate payloads against the hook schema in CI with a unit test per hook type.","After version upgrades, diff the hook schema between producer and adapter."],"tags":["rust","validation","schema","hooks"],"backgroundTag":"schema-validation-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"}