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

  1. Match on the HTTP status: 429/5xx → retry with exponential backoff and jitter; 4xx (other than 429) → treat as non-retryable and surface/log
  2. If 429s dominate, reduce request concurrency or add client-side rate limiting for fetch_following_list
  3. Check Strato service health/status dashboards if failures are broad
  4. 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

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


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/52ffc39641965104. Report an issue: GitHub.