unicity-aos/aos-ce · critical
aos-mcp-broker: call install_aos before handling traffic
Error message
aos-mcp-broker: call install_aos before handling traffic
What it means
This is a panic from an internal OnceCell-style registry: `McpIdentity` was never installed, so `identity()` cannot return a value and the `.expect` aborts. The broker requires `install_aos` (which populates IDENTITY) to run before any MCP traffic handling. It is an initialization-ordering guard, not a data error.
Solutions
- Call `install_aos(...)` with the proper McpIdentity at process startup, before any request handling or topic/tag lookup.
- Check that the code path calling log_tag/mcp_tool_prefix/tools_list_topic/audit_topic is not executed before initialization (move it after init or defer it).
- In tests, add a setup fixture that calls install_aos once before the helpers under test.
Example fix
// before let tag = broker::log_tag(); // after broker::install_aos(&identity_config); let tag = broker::log_tag();
Defensive patterns
Strategy: try-catch
Validate before calling
// Rust: guard before calling helpers assert!(broker::is_initialized(), "call install_aos before handling traffic"); let tag = broker::log_tag();
Type guard
fn identity_installed() -> bool { broker::is_initialized() } Try / catch
// Use std::panic::catch_unwind only at the boundary; the real fix is init ordering
let tag = std::panic::catch_unwind(broker::log_tag)
.unwrap_or_else(|_| "uninitialized"); Prevention
- Call install_aos as the first statement in main before spawning any handlers.
- Add an integration test that exercises every public broker helper in a fresh process.
- Route helper access through a single init-checked entry point.
When it happens
Trigger: Calling `log_tag()`, `mcp_tool_prefix()`, `tools_list_topic()`, or `audit_topic()` before `install_aos(...)` has been invoked; also any request handler path that transitively calls `identity()` during early startup or in tests that skip setup.
Common situations: Forgetting broker initialization in a new binary entrypoint, constructing MCP tool names/audit topics in static or lazy contexts that run before install, or writing unit tests that call helper functions without a setup harness.
Related errors
- aos-mcp: malformed hook ingress
- aos-mcp: caller unavailable for
- aos-mcp: malformed host-hook bridge response
- aos-mcp: caller unavailable for host-hook response
AI-assisted analysis of unicity-aos/aos-ce@f6f22024fb (2026-09-13).
Data as JSON: /api/errors/ae9acca14fcd0d34.
Report an issue: GitHub.
Appendix: source
Thrown at crates/aos-mcp-broker/src/profile.rs:25
static IDENTITY: OnceLock<&'static McpIdentity> = OnceLock::new();
/// Install the singleton AOS identity if it is not already set.
pub fn install_aos() {
match IDENTITY.set(&McpIdentity::AOS) {
Ok(()) => {}
Err(existing) => assert!(
core::ptr::eq(existing, &McpIdentity::AOS),
"aos-mcp-broker: identity already installed"
),
}
}
#[inline]
fn identity() -> &'static McpIdentity {
IDENTITY
.get()
.copied()
.expect("aos-mcp-broker: call install_aos before handling traffic")
}
#[inline]
pub(crate) fn log_tag() -> &'static str {
identity().log_tag
}
#[inline]
pub(crate) fn mcp_tool_prefix() -> &'static str {
identity().mcp_tool_prefix
}
#[inline]
pub(crate) fn tools_list_topic() -> &'static str {
identity().tools_list_topic
}
#[inline]View on GitHub (pinned to f6f22024fb)