xai-org/x-algorithm · warning · anyhow::Error

ttl=-1

Error message

ttl=-1

What it means

Returned by fetch_following_list_internal when the Strato response body is exactly {"ttl":-1}. That is Strato's sentinel meaning the user has no following list (not found / no data), reported via the not_found metric label. It's an error-shaped signal for a semantically empty result.

Source

Thrown at thunder/strato_client.rs:139

        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)
            }
            Err(e) => {
                metrics::STRATO_REQUESTS
                    .with_label_values(&["fetch_following_list", "parse_error"])
                    .inc();
                warn!(
                    "Failed to parse following list response for {}: {}. Response preview: {}",
                    user_id,
                    e,
                    &text[..text.len().min(300)]

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Treat ttl=-1 as an empty list rather than propagating the error: catch this specific message and return an empty Vec or None
  2. If the caller distinguishes 'no data' from 'error', map this to an Option<Vec<String>>::None result
  3. Do not retry — this is a deterministic Strato signal, not a transient failure
  4. Log/metric it separately from real fetch failures to avoid alert noise

Example fix

// before
// caller:
let following = client.fetch_following_list(user_id).await?;

// after
let following = match client.fetch_following_list(user_id).await {
    Ok(f) => f,
    Err(e) if e.to_string().contains("ttl=-1") => Vec::new(), // no following list
    Err(e) => return Err(e),
};
Defensive patterns

Strategy: fallback

Validate before calling

null

Type guard

fn is_no_following_list(e: &anyhow::Error) -> bool { e.to_string() == "ttl=-1" }

Try / catch

match client.fetch_following_list(u).await { Ok(f) => f, Err(e) if is_no_following_list(&e) => Vec::new(), Err(e) => Err(e) }

Prevention

When it happens

Trigger: Calling fetch_following_list for a user with no following data in Strato — new/suspended/deleted accounts or users whose following list was never materialized.

Common situations: Bots or brand-new accounts with no following; deleted/suspended users; lookups racing account deletion; tests using nonexistent user ids.

Related errors


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