{"record":{"id":"2429be4bee1feff2","repo":"tonhowtf/omniget","slug":"o-pin-it-nao-redirecionou","errorCode":null,"errorMessage":"o pin.it nao redirecionou","messagePattern":"o pin\\.it nao redirecionou","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pinterest/api.rs","lineNumber":1217,"sourceCode":"            {\n                if !out.contains(&t) {\n                    out.push(t);\n                }\n            }\n        }\n        Ok(out)\n    }\n\n    /// Expande `pin.it/xxxx` para a URL final.\n    pub async fn resolve_short(&self, code: &str) -> anyhow::Result<String> {\n        let url = format!(\"https://api.pinterest.com/url_shortener/{}/redirect/\", code);\n        let resp = self.http.get(&url).send().await?;\n        let mut loc = resp\n            .headers()\n            .get(reqwest::header::LOCATION)\n            .and_then(|v| v.to_str().ok())\n            .map(|v| v.to_string())\n            .ok_or_else(|| anyhow!(\"o pin.it nao redirecionou\"))?;\n        // às vezes há um segundo pulo (pinterest.com/pin/…/sent/?…)\n        for _ in 0..3 {\n            if parse_target(&loc)\n                .map(|t| !matches!(t, Target::Short { .. }))\n                .unwrap_or(false)\n                && !loc.ends_with(\"pinterest.com/\")\n            {\n                break;\n            }\n            let r = self.http.get(&loc).send().await?;\n            match r\n                .headers()\n                .get(reqwest::header::LOCATION)\n                .and_then(|v| v.to_str().ok())\n            {\n                Some(l) => loc = l.to_string(),\n                None => break,\n            }","sourceCodeStart":1199,"sourceCodeEnd":1235,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pinterest/api.rs#L1199-L1235","documentation":"resolve_short() issues a GET to a pin.it short link and reads the Location response header to follow the redirect manually. If the response carries no Location header at all, the library raises \"o pin.it nao redirecionou\". Pinterest short links are expected to 3xx-redirect to a canonical /pin/<id>/ URL; a non-redirect response means the link is dead or Pinterest answered with an error/interstitial page.","triggerScenarios":"Calling resolve_short (directly or via feed_for with Target::Short) when the pin.it code is expired/invalid, or Pinterest replies 200 (block page) / 4xx / 5xx without a Location header.","commonSituations":"Old pin.it links shared in chats that were later deleted; headless clients whose requests Pinterest answers with an anti-bot 200 page; proxy stripping redirect headers.","solutions":["Validate the pin.it URL resolves in a normal browser before feeding it to the library.","Regenerate a fresh pin.it link or ask the user for the full pinterest.com/pin/<id>/ URL.","Inspect the HTTP status of the response (log it) — a 404/410 means the short link is gone.","Retry with backoff in case of a transient interstitial response."],"exampleFix":"// before\nlet target = api.resolve_short(code).await?;\n// after\nlet target = api.resolve_short(code).await\n    .map_err(|e| { log::warn!(\"pin.it/{code} did not redirect: {e}\"); MyError::BadShareLink(code.clone()) })?;","handlingStrategy":"fallback","validationCode":"// Check the short-link shape up front\nfn is_pinit_url(u: &str) -> bool { u.starts_with(\"https://pin.it/\") && u.len() > \"https://pin.it/\".len() }","typeGuard":"null","tryCatchPattern":"let url = match api.resolve_short(code).await {\n    Ok(u) => u,\n    Err(_) => return Err(anyhow!(\"pin.it/{code} is dead; ask for the full pin URL\")),\n};","preventionTips":["Prefer full pinterest.com/pin/<id>/ URLs over pin.it links","Test short links in a browser before automation","Log HTTP status when resolution fails to spot 404/410","Ask users to re-share links that expired"],"tags":["pinterest","redirect","http","short-link"],"backgroundTag":"missing-redirect-location","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}