astrid-runtime/astrid · error · GatewayError::Internal
gateway is not wired to a live event bus; agent approval una
Error message
gateway is not wired to a live event bus; agent approval unavailable
What it means
This is an Internal (500) error thrown by the agent approval endpoint when GatewayState.event_bus is None. The gateway can be built without a live event bus (e.g. in reduced/test configurations or when the bus wiring failed at startup), and approval responses require publishing an event to the bus, so the route refuses to run rather than silently dropping the approval.
Source
Thrown at crates/astrid-gateway/src/routes/agent.rs:512
post,
path = "/api/agent/approval-response",
tag = "agent",
request_body = ApprovalResponseRequest,
responses(
(status = 202, description = "Approval decision accepted and published onto the approval reply topic."),
(status = 400, body = ErrorBody, description = "Malformed request id or unsupported decision."),
(status = 401, body = ErrorBody, description = "Missing / invalid bearer."),
(status = 500, body = ErrorBody, description = "Gateway not wired to a live event bus."),
)
)]
pub async fn post_approval_response(
State(state): State<Arc<GatewayState>>,
req: Request<axum::body::Body>,
) -> GatewayResult<impl IntoResponse> {
let caller = caller_from(&req)?.clone();
let Some(bus) = state.event_bus.clone() else {
return Err(GatewayError::Internal(anyhow::anyhow!(
"gateway is not wired to a live event bus; agent approval unavailable"
)));
};
let body: ApprovalResponseRequest = crate::routes::principals::read_json_body(req).await?;
body.validate()
.map_err(|m| GatewayError::BadRequest(m.to_string()))?;
publish_approval_response(&bus, caller.principal.as_str(), body);
Ok(StatusCode::ACCEPTED)
}
/// Publish an elicit answer onto the per-request reply topic the host lifecycle
/// waiter is blocked on (`astrid.v1.elicit.response.{request_id}`), stamped with
/// the caller's verified `principal`.
///
/// Split out of [`post_elicit_response`] so the message construction +View on GitHub (pinned to affd8760f4)
Solutions
- Wire a live event bus into GatewayState at gateway startup (the code at src/lib.rs only uses the bus when Some).
- If the bus failed to initialize, fix the underlying startup error and restart the gateway.
- Do not route agent-approval traffic to gateway instances deployed without an event bus; gate the route on bus availability.
- In tests, construct GatewayState with a real (or stub) event bus instead of event_bus: None.
Example fix
// before: state built without a bus
let state = GatewayState { event_bus: None, .. };
// after: build and wire the bus at startup
let bus = EventBus::connect(&config.bus_addr).await?;
let state = GatewayState { event_bus: Some(Arc::new(bus)), .. }; Defensive patterns
Strategy: try-catch
Validate before calling
// caller-side check before calling the approval endpoint
if (!gatewayHealth.features?.eventBus) throw new Error('gateway has no event bus; approvals disabled'); Type guard
fn has_event_bus(state: &GatewayState) -> bool {
state.event_bus.is_some()
} Try / catch
try {
await fetch('/api/agent/approval-response', { method: 'POST', body });
} catch (e) {
if (e.status === 500 && /not wired to a live event bus/.test(e.message)) {
// surface 'approvals unavailable' and stop retrying
}
} Prevention
- Deploy gateways with an event bus wired if any approval flows are expected.
- Add a readiness probe that reports event_bus presence so traffic is routed away from bus-less instances.
- In tests, never ship a GatewayState with event_bus: None into integration suites covering approvals.
When it happens
Trigger: Calling POST /api/agent/approval-response (post_approval_response handler) while the gateway was constructed with event_bus: None — i.e. the server was started without a live event bus wired into GatewayState.
Common situations: Gateway started in a degraded/test/offline mode where the event bus is not instantiated; a startup bug or config change that skips bus construction; hitting an approval endpoint on a node whose event bus failed to initialize.
Related errors
- gateway is not wired to a live audit log; historical-query u
- gateway is not wired to a live event bus; audit stream unava
- gateway is not wired to a live event bus; model registry una
- lifecycle manifest declares environment state but no durable
- no corpus selected; omit --no-synthetic or pass a corpus or
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/14bd8beabc1729c0.
Report an issue: GitHub.