{"record":{"id":"52ffc39641965104","repo":"xai-org/x-algorithm","slug":"response-status-to-string","errorCode":null,"errorMessage":"response.status().to_string()","messagePattern":"response\\.status\\(\\)\\.to_string\\(\\)","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"thunder/strato_client.rs","lineNumber":130,"sourceCode":"            .send()\n            .await\n            .context(\"Failed to fetch following list\")?;\n\n        let duration = start.elapsed();\n        metrics::STRATO_REQUEST_DURATION\n            .with_label_values(&[\"fetch_following_list\"])\n            .observe(duration.as_secs_f64());\n\n        if !response.status().is_success() {\n            metrics::STRATO_REQUESTS\n                .with_label_values(&[\"fetch_following_list\", \"error\"])\n                .inc();\n            warn!(\n                \"Following list fetch failed for {}: {}\",\n                user_id,\n                response.status()\n            );\n            return Err(anyhow!(response.status().to_string()));\n        }\n\n        let text = response.text().await?;\n\n        if text == \"{\\\"ttl\\\":-1}\" {\n            metrics::STRATO_REQUESTS\n                .with_label_values(&[\"fetch_following_list\", \"not_found\"])\n                .inc();\n            return Err(anyhow!(\"ttl=-1\"));\n        }\n\n        match serde_json::from_str::<StratoResponse<Vec<String>>>(&text) {\n            Ok(result) => {\n                metrics::STRATO_REQUESTS\n                    .with_label_values(&[\"fetch_following_list\", \"success\"])\n                    .inc();\n                Ok(result.v)\n            }","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/thunder/strato_client.rs#L112-L148","documentation":"Returned by fetch_following_list_internal when the Strato HTTP response has a non-success status code; the error message is just response.status().to_string() (e.g. \"404 Not Found\"), so only the HTTP status identifies the problem. A warn log with the user_id and status is emitted alongside.","triggerScenarios":"Calling fetch_following_list for a user when the Strato service returns 4xx/5xx: rate limiting (429), upstream server errors (5xx), bad request, or auth failures against the Strato endpoint.","commonSituations":"Strato service degradation or 5xx during incidents; 429 rate limiting under heavy follower-list fetching; auth token expiry; requesting during a deploy window.","solutions":["Match on the HTTP status: 429/5xx → retry with exponential backoff and jitter; 4xx (other than 429) → treat as non-retryable and surface/log","If 429s dominate, reduce request concurrency or add client-side rate limiting for fetch_following_list","Check Strato service health/status dashboards if failures are broad","Include the status code and user_id in the error context instead of relying on the warn log"],"exampleFix":"// before\nreturn Err(anyhow!(response.status().to_string()));\n\n// after\nlet status = response.status();\nreturn Err(anyhow::anyhow!(\n    \"strato fetch_following_list for user {user_id} failed with HTTP {status} (retryable={})\",\n    status.is_server_error() || status.as_u16() == 429\n));","handlingStrategy":"retry","validationCode":"null","typeGuard":null,"tryCatchPattern":"let fl = match client.fetch_following_list(u).await { Ok(f) => f, Err(e) if status_is_retryable(&e) => retry(...).await?, Err(e) => return Err(e) };","preventionTips":["Match on HTTP status text to classify retryability","Rate-limit client-side to avoid 429s","Cache following lists with a TTL to reduce call volume"],"tags":["http","strato","status-code","social-graph","rust"],"backgroundTag":"http-error-status","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}