xai-org/x-algorithm · error · anyhow::Error
response.status().to_string()
Error message
response.status().to_string()
What it means
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.
Source
Thrown at thunder/strato_client.rs:130
.send()
.await
.context("Failed to fetch following list")?;
let duration = start.elapsed();
metrics::STRATO_REQUEST_DURATION
.with_label_values(&["fetch_following_list"])
.observe(duration.as_secs_f64());
if !response.status().is_success() {
metrics::STRATO_REQUESTS
.with_label_values(&["fetch_following_list", "error"])
.inc();
warn!(
"Following list fetch failed for {}: {}",
user_id,
response.status()
);
return Err(anyhow!(response.status().to_string()));
}
let text = response.text().await?;
if text == "{\"ttl\":-1}" {
metrics::STRATO_REQUESTS
.with_label_values(&["fetch_following_list", "not_found"])
.inc();
return Err(anyhow!("ttl=-1"));
}
match serde_json::from_str::<StratoResponse<Vec<String>>>(&text) {
Ok(result) => {
metrics::STRATO_REQUESTS
.with_label_values(&["fetch_following_list", "success"])
.inc();
Ok(result.v)
}View on GitHub (pinned to 24c60942c5)
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
Example fix
// before
return Err(anyhow!(response.status().to_string()));
// after
let status = response.status();
return Err(anyhow::anyhow!(
"strato fetch_following_list for user {user_id} failed with HTTP {status} (retryable={})",
status.is_server_error() || status.as_u16() == 429
)); Defensive patterns
Strategy: retry
Validate before calling
null
Try / catch
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) }; Prevention
- 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
When it happens
Trigger: 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.
Common situations: Strato service degradation or 5xx during incidents; 429 rate limiting under heavy follower-list fetching; auth token expiry; requesting during a deploy window.
Related errors
- ttl=-1
- {metric_label} fetch failed after retries: {e}
- {e}
- Strato error code {}: {}
- Post metadata is required
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/52ffc39641965104.
Report an issue: GitHub.