{"record":{"id":"5c9cd21ecfe3e7b2","repo":"astrid-runtime/astrid","slug":"build-host-state","errorCode":null,"errorMessage":"build_host_state","messagePattern":"build_host_state","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-hooks/src/handler/wasm.rs","lineNumber":534,"sourceCode":"    }\n\n    /// FIX 2 regression: the operator `[http]` host policy reaches the hook\n    /// `HostState`. A non-default `http_limits` on the handler must be reflected\n    /// on the built `HostState` (it previously hardcoded `HttpLimits::default()`,\n    /// so a configured limit never reached a WASM hook's HTTP calls).\n    #[tokio::test(flavor = \"multi_thread\")]\n    async fn test_hook_host_state_reflects_configured_http_limits() {\n        let configured = astrid_capsule::HttpLimits {\n            max_concurrent_streams: 2,\n            default_total_timeout: Duration::from_secs(7),\n            ..astrid_capsule::HttpLimits::default()\n        };\n        let mut handler = WasmHandler::new(PathBuf::from(\"/tmp\"));\n        handler.http_limits = configured;\n\n        let host_state = handler\n            .build_host_state(\"hook-test\")\n            .expect(\"build_host_state\");\n\n        assert_eq!(host_state.http_limits.max_concurrent_streams, 2);\n        assert_eq!(\n            host_state.http_limits.default_total_timeout,\n            Duration::from_secs(7),\n            \"the configured [http] limit must reach the hook HostState, not default()\"\n        );\n    }\n}\n","sourceCodeStart":516,"sourceCodeEnd":544,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-hooks/src/handler/wasm.rs#L516-L544","documentation":"Test assertion in `test_hook_host_state_reflects_configured_http_limits`: after setting `handler.http_limits` from config, `build_host_state(\"hook-test\")` must succeed and propagate those limits into the hook `HostState`. The `expect(\"build_host_state\")` fires when `build_host_state` returns `None`/`Err`, so the configured HTTP limits could not be reflected.","triggerScenarios":"Calling `handler.build_host_state(\"hook-test\")` on a `WasmHandler` with `http_limits` set, when construction fails — e.g. missing required fields in host state, failure to assemble KV/config, or the handler's engine/component not yet initialized when required.","commonSituations":"A refactor changing `build_host_state`'s prerequisites (e.g. requiring an initialized engine or KV store) while the test only sets `http_limits`; misconfigured `HttpLimits` values rejected during validation.","solutions":["Initialize whatever new prerequisite `build_host_state` requires before calling it (engine, KV, config).","Check validation inside `build_host_state` accepts the configured limits used in the test.","Update the test fixture if `WasmHandler::new` signature/requirements changed.","Make the expect message include the underlying error to speed diagnosis."],"exampleFix":"// before\n.expect(\"build_host_state\");\n// after\n.unwrap_or_else(|| panic!(\"build_host_state returned None for hook-test with limits {configured:?}\"));","handlingStrategy":"validation","validationCode":"// Rust (test): ensure every field build_host_state needs is present before the call\nassert!(handler.http_limits.max_concurrent_streams > 0, \"http_limits must be fully configured\");","typeGuard":null,"tryCatchPattern":"// Rust: keep error context in the test assertion\nlet host_state = handler.build_host_state(\"hook-test\")\n    .unwrap_or_else(|| panic!(\"build_host_state failed; http_limits={:?}\", handler.http_limits));","preventionTips":["Update test fixtures whenever WasmHandler::new or build_host_state gains prerequisites.","Build HostState through a shared constructor used by both prod and tests.","Validate HttpLimits config at load time so bad values fail early.","Avoid Option-returning builders in tests; prefer Result with reasons."],"tags":["rust","test-assertion","wasm","http-limits","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}