tonhowtf/omniget · error
Pinterest respondeu HTTP
Error message
Pinterest respondeu HTTP {} sem JSON ({}) What it means
The Pinterest API client received an HTTP response whose status was handled as an error, but the body could not be deserialized into JSON (resp.json() failed). The message includes the HTTP status and the deserialization error, indicating Pinterest answered with non-JSON content (HTML error page, empty body, gateway noise) on a non-success path.
Solutions
- Log the raw response text on parse failure to see what Pinterest actually returned.
- Retry with backoff — these bodies usually accompany transient 5xx/challenge responses.
- Ensure requests include proper headers (User-Agent, auth cookies/token) so Pinterest returns JSON error payloads.
- Route the request through a residential/proper egress IP if a datacenter IP is triggering WAF HTML pages.
Example fix
// before
let body: Value = resp.json().await?;
// after
let text = resp.text().await?;
let body: Value = serde_json::from_str(&text)
.with_context(|| format!("non-JSON response ({}): {}", status, &text[..text.len().min(200)]))?; Defensive patterns
Strategy: retry
Try / catch
match fetch() {
Err(e) if e.to_string().contains("sem JSON") => {
// transient HTML/challenge/5xx body: back off and retry
tokio::time::sleep(backoff).await;
retry();
}
other => other?,
} Prevention
- Send browser-like headers (User-Agent, Accept) so Pinterest returns JSON error payloads.
- Add exponential backoff with jitter for transient non-JSON responses.
- Avoid datacenter egress IPs that trigger WAF HTML challenge pages.
- Log raw response bodies on parse failure for diagnostics.
When it happens
Trigger: Hitting a Pinterest endpoint during an error condition (rate limiting, outage, proxy intercept) so the server returns an HTML/empty body instead of JSON, with a non-OK status.
Common situations: Corporate proxies or CAPTCHA/challenge pages returning HTML; Pinterest 5xx outages returning plain-text error pages; auth failures returning empty bodies; VPN/datacenter IPs blocked by Pinterest's WAF.
Understand the failure class
Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — this error's family across 28 libraries.
Related errors
- o Reddit respondeu algo que não é JSON
- LibreTranslate: resposta invalida
- FxTwitter: resposta invalida
- HTTP ao acessar pin
- HTTP ao acessar pin
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/97a54e03362c958a.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pinterest/api.rs:895
let mut attempt = 0u32;
loop {
attempt += 1;
let req = self
.http
.get(&url)
.query(&[("source_url", source_url), ("data", data.as_str())])
.header("X-Pinterest-Source-Url", source_url);
let resp = self.apply_cookie(req).send().await?;
let status = resp.status();
if (status.as_u16() == 429 || status.is_server_error()) && attempt < 4 {
tokio::time::sleep(Duration::from_millis(800 * attempt as u64 * attempt as u64))
.await;
continue;
}
let body: Value = match resp.json().await {
Ok(v) => v,
Err(e) => {
return Err(anyhow!(
"Pinterest respondeu HTTP {} sem JSON ({})",
status,
e
))
}
};
let rr = &body["resource_response"];
if rr["status"].as_str() != Some("success") {
let msg = rr["message"]
.as_str()
.or_else(|| rr["error"]["message"].as_str())
.unwrap_or("resposta sem status de sucesso");
let code = rr["error"]["http_status"]
.as_u64()
.unwrap_or(status.as_u16() as u64);
if code == 404 {
return Err(anyhow!(
"nao encontrado no Pinterest (privado, removido ou URL errada): {}",View on GitHub (pinned to 8600b91f42)