astrid-runtime/astrid · error
build_host_state
Error message
build_host_state
What it means
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.
Source
Thrown at crates/astrid-hooks/src/handler/wasm.rs:534
}
/// FIX 2 regression: the operator `[http]` host policy reaches the hook
/// `HostState`. A non-default `http_limits` on the handler must be reflected
/// on the built `HostState` (it previously hardcoded `HttpLimits::default()`,
/// so a configured limit never reached a WASM hook's HTTP calls).
#[tokio::test(flavor = "multi_thread")]
async fn test_hook_host_state_reflects_configured_http_limits() {
let configured = astrid_capsule::HttpLimits {
max_concurrent_streams: 2,
default_total_timeout: Duration::from_secs(7),
..astrid_capsule::HttpLimits::default()
};
let mut handler = WasmHandler::new(PathBuf::from("/tmp"));
handler.http_limits = configured;
let host_state = handler
.build_host_state("hook-test")
.expect("build_host_state");
assert_eq!(host_state.http_limits.max_concurrent_streams, 2);
assert_eq!(
host_state.http_limits.default_total_timeout,
Duration::from_secs(7),
"the configured [http] limit must reach the hook HostState, not default()"
);
}
}
View on GitHub (pinned to affd8760f4)
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.
Example fix
// before
.expect("build_host_state");
// after
.unwrap_or_else(|| panic!("build_host_state returned None for hook-test with limits {configured:?}")); Defensive patterns
Strategy: validation
Validate before calling
// Rust (test): ensure every field build_host_state needs is present before the call assert!(handler.http_limits.max_concurrent_streams > 0, "http_limits must be fully configured");
Try / catch
// Rust: keep error context in the test assertion
let host_state = handler.build_host_state("hook-test")
.unwrap_or_else(|| panic!("build_host_state failed; http_limits={:?}", handler.http_limits)); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- failed to create wasmtime engine for hooks
- WASM capsule has no BLAKE3 hash in meta.json
- stability quantiles must lie strictly between zero and 10,00
- stability quantiles select duplicate boundary neighborhoods
- No Cargo build target selected. Set `[build] target = "wasm3
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/5c9cd21ecfe3e7b2.
Report an issue: GitHub.