{"record":{"id":"ffe75c1b546654b6","repo":"xai-org/grok-build","slug":"op-failed","errorCode":null,"errorMessage":"{op} failed: {}","messagePattern":"(.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/agent/session_registry_client.rs","lineNumber":228,"sourceCode":"    }\n\n    /// Non-auth headers only -- the `Authorization` header lives in\n    /// `send_authed` so it picks up freshly-refreshed tokens.\n    fn add_common_headers(&self, builder: RequestBuilder) -> RequestBuilder {\n        builder\n    }\n\n    fn check_response(\n        &self,\n        response: reqwest::Response,\n        stamp: Option<&xai_grok_auth::StampedBearerSuffix>,\n        op: &str,\n    ) -> anyhow::Error {\n        if response.status() == reqwest::StatusCode::UNAUTHORIZED {\n            self.record_401_attribution(op, stamp);\n            anyhow::anyhow!(\"{op}: {}\", self.credentials.auth_error_hint())\n        } else {\n            anyhow::anyhow!(\"{op} failed: {}\", response.status())\n        }\n    }\n\n    /// Emit a single `auth 401 attribution` log entry tagged with\n    /// `consumer = \"SessionRegistryClient.<op>\"`. The op string is the\n    /// operation name passed to `check_response` (e.g.,\n    /// `\"session register\"`).\n    ///\n    /// `stamp` is what the middleware put on the wire (see\n    /// [`xai_grok_auth::StampedBearerSuffix`] for why never a re-resolution).\n    fn record_401_attribution(&self, op: &str, stamp: Option<&xai_grok_auth::StampedBearerSuffix>) {\n        if let Some(manager) = self.credentials.auth_manager() {\n            crate::auth::attribution::record_consumer_401(\n                manager.as_ref(),\n                self.session_id.as_deref(),\n                crate::auth::attribution::ConsumerKind::SessionRegistryClient,\n                op,\n                stamp.map(|s| s.0.as_str()),","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/agent/session_registry_client.rs#L210-L246","documentation":"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.","triggerScenarios":"Registry calls returning 4xx/5xx other than 401: 404 unknown session id, 409 conflict on update/finalize, 429 rate-limit, 500/503 server errors.","commonSituations":"Updating a session that was already finalized, wrong session id in search/get_session, registry outage or deploy, aggressive retry loops hitting 429.","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"],"exampleFix":"// before\nregistry.finalize(&session_id).await?; // 409 if already finalized\n// after\nmatch registry.get_session(&session_id).await {\n    Ok(s) if s.finalized => {} // already done\n    _ => registry.finalize(&session_id).await?,\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match op_result {\n    Err(e) if e.to_string().contains(\"429\") => backoff_retry().await,\n    Err(e) if e.to_string().contains(\"409\") => reconcile_state_then_retry().await,\n    Err(e) if e.to_string().contains(\"failed: 5\") => retry_with_limit(3).await,\n    other => other?,\n}","preventionTips":["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"],"tags":["http","api","status-code"],"backgroundTag":"http-4xx-5xx-response","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}