xai-org/grok-build · error
{op} failed: {}
Error message
{op} failed: {} What it means
check_response maps any non-401 non-success status from the session registry to '{op} failed: <status>'. It is the generic error-path converter for all registry operations.
Source
Thrown at crates/codegen/xai-grok-shell/src/agent/session_registry_client.rs:228
}
/// Non-auth headers only -- the `Authorization` header lives in
/// `send_authed` so it picks up freshly-refreshed tokens.
fn add_common_headers(&self, builder: RequestBuilder) -> RequestBuilder {
builder
}
fn check_response(
&self,
response: reqwest::Response,
stamp: Option<&xai_grok_auth::StampedBearerSuffix>,
op: &str,
) -> anyhow::Error {
if response.status() == reqwest::StatusCode::UNAUTHORIZED {
self.record_401_attribution(op, stamp);
anyhow::anyhow!("{op}: {}", self.credentials.auth_error_hint())
} else {
anyhow::anyhow!("{op} failed: {}", response.status())
}
}
/// Emit a single `auth 401 attribution` log entry tagged with
/// `consumer = "SessionRegistryClient.<op>"`. The op string is the
/// operation name passed to `check_response` (e.g.,
/// `"session register"`).
///
/// `stamp` is what the middleware put on the wire (see
/// [`xai_grok_auth::StampedBearerSuffix`] for why never a re-resolution).
fn record_401_attribution(&self, op: &str, stamp: Option<&xai_grok_auth::StampedBearerSuffix>) {
if let Some(manager) = self.credentials.auth_manager() {
crate::auth::attribution::record_consumer_401(
manager.as_ref(),
self.session_id.as_deref(),
crate::auth::attribution::ConsumerKind::SessionRegistryClient,
op,
stamp.map(|s| s.0.as_str()),View on GitHub (pinned to bc7f02eddd)
Solutions
- Read the status code in the message and handle accordingly: 404 -> verify session id, 409 -> fetch current state before update, 429 -> back off and retry
- Check registry service health/logs if 5xx
- For finalize conflicts, treat the session as already finalized rather than retrying blindly
Example fix
// before
registry.finalize(&session_id).await?; // 409 if already finalized
// after
match registry.get_session(&session_id).await {
Ok(s) if s.finalized => {} // already done
_ => registry.finalize(&session_id).await?,
} Defensive patterns
Strategy: retry
Try / catch
match op_result {
Err(e) if e.to_string().contains("429") => backoff_retry().await,
Err(e) if e.to_string().contains("409") => reconcile_state_then_retry().await,
Err(e) if e.to_string().contains("failed: 5") => retry_with_limit(3).await,
other => other?,
} Prevention
- Inspect the status code embedded in the message before choosing a recovery path
- Never retry blindly on 409 or 404
- Add jittered backoff for 429/5xx
When it happens
Trigger: Registry calls returning 4xx/5xx other than 401: 404 unknown session id, 409 conflict on update/finalize, 429 rate-limit, 500/503 server errors.
Common situations: Updating a session that was already finalized, wrong session id in search/get_session, registry outage or deploy, aggressive retry loops hitting 429.
Related errors
- send failed: {body}
- screen query failed: {body}
- resize failed: {body}
- wait failed: {body}
- stop failed: {body}
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/ffe75c1b546654b6.
Report an issue: GitHub.