tonhowtf/omniget · error · anyhow::Error

Bluesky API retornou HTTP

Error message

Bluesky API retornou HTTP {}

What it means

In `fetch_post` (src-tauri/src/platforms/bluesky/mod.rs:139), the request to the Bluesky AppView (`app.bsky.feed.getPostThread`) returned a non-2xx HTTP status, and the code converts it into the error "Bluesky API retornou HTTP {status}". This fires before the response body is parsed, so the failure is at the HTTP transport/status level.

Solutions

  1. Check the status code in the message: 429 means back off and retry later; 5xx means wait for Bluesky recovery.
  2. Verify the constructed at:// URI and handle are valid before the request.
  3. Add retry with exponential backoff for 429/5xx responses.
  4. Inspect the response body (currently discarded) for the AppView's structured error message.

Example fix

// before
if !response.status().is_success() {
    return Err(anyhow!("Bluesky API retornou HTTP {}", response.status()));
}
// after
if !response.status().is_success() {
    let status = response.status();
    let body = response.text().await.unwrap_or_default();
    anyhow::bail!("Bluesky API retornou HTTP {}: {}", status, body);
}
Defensive patterns

Strategy: retry

Try / catch

for attempt in 0..3 {
    match self.fetch_post(&user, &post_id).await {
        Ok(json) => return Ok(json),
        Err(e) if e.to_string().contains("HTTP 429") || e.to_string().contains("HTTP 5") => {
            tokio::time::sleep(std::time::Duration::from_secs(2 << attempt)).await;
        }
        Err(e) => return Err(e),
    }
}

Prevention

When it happens

Trigger: The GET to the AppView endpoint returns statuses like 400 (malformed uri), 403, 429 (rate limit), or 5xx; any `!response.status().is_success()` triggers this branch.

Common situations: Bluesky rate limiting during heavy use; AppView outages (5xx); an incorrectly constructed at:// URI producing a 400; transient network/proxy failures surfaced as error statuses.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/74351eef0ff03638. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/platforms/bluesky/mod.rs:139

        let segments: Vec<&str> = parsed.path().split('/').filter(|s| !s.is_empty()).collect();
        if segments.len() >= 4 && segments[0] == "profile" && segments[2] == "post" {
            return Some((segments[1].to_string(), segments[3].to_string()));
        }
        None
    }

    async fn fetch_post(&self, user: &str, post_id: &str) -> anyhow::Result<serde_json::Value> {
        let uri = format!("at://{}/app.bsky.feed.post/{}", user, post_id);
        let url = format!(
            "{}?depth=0&parentHeight=0&uri={}",
            API_BASE,
            urlencoding::encode(&uri)
        );

        let response = self.client.get(&url).send().await?;

        if !response.status().is_success() {
            return Err(anyhow!("Bluesky API retornou HTTP {}", response.status()));
        }

        let json: serde_json::Value = response.json().await?;

        if let Some(error) = json.get("error").and_then(|e| e.as_str()) {
            return match error {
                "NotFound" | "InternalServerError" => Err(anyhow!("Post not available")),
                "InvalidRequest" => Err(anyhow!("Unsupported link")),
                _ => Err(anyhow!("Erro da API: {}", error)),
            };
        }

        Ok(json)
    }
}

enum BlueskyMedia {
    Video { hls_url: String },

View on GitHub (pinned to 8600b91f42)