{"record":{"id":"c19fc2d678d31e9c","repo":"tonhowtf/omniget","slug":"could-not-resolve-share-link","errorCode":null,"errorMessage":"Could not resolve share link","messagePattern":"Could not resolve share link","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/instagram.rs","lineNumber":129,"sourceCode":"        false\n    }\n\n    fn is_reel_url(url: &str) -> bool {\n        if let Ok(parsed) = url::Url::parse(url) {\n            let path = parsed.path().to_lowercase();\n            return path.starts_with(\"/reel/\") || path.starts_with(\"/reels/\");\n        }\n        false\n    }\n\n    async fn resolve_share_link(&self, share_id: &str) -> anyhow::Result<String> {\n        let url = format!(\"https://www.instagram.com/share/{}/\", share_id);\n\n        let response = self.redirect_client.get(&url).send().await?;\n        let final_url = response.url().to_string();\n\n        if final_url.contains(\"/share/\") || final_url == url {\n            return Err(anyhow!(\"Could not resolve share link\"));\n        }\n\n        Ok(final_url)\n    }\n\n    fn regex_extract(pattern: &str, text: &str) -> Option<String> {\n        let re = Regex::new(pattern).ok()?;\n        re.captures(text)?.get(1).map(|m| m.as_str().to_string())\n    }\n\n    fn extract_object_entry(name: &str, html: &str) -> Option<serde_json::Value> {\n        let pattern = format!(r#\"\\[\"{}\",.*?,(\\{{.*?\\}}),\\d+\\]\"#, regex::escape(name));\n        let re = Regex::new(&pattern).ok()?;\n        let json_str = re.captures(html)?.get(1)?.as_str();\n        serde_json::from_str(json_str).ok()\n    }\n\n    fn extract_number_from_query(name: &str, html: &str) -> Option<String> {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/instagram.rs#L111-L147","documentation":"Instagram share links (instagram.com/share/<id>/) are resolved by following redirects with redirect_client and reading the final URL. If the redirect chain still lands on a /share/ URL or the original URL — i.e. Instagram did not redirect — the share ID is considered unusable and this error is thrown.","triggerScenarios":"get_media_info with a share URL whose resolve_share_link response URL contains \"/share/\" or equals the input: expired/invalid share ID, Instagram not serving a redirect (bot protection, rate limiting), or a network client configured with redirects disabled.","commonSituations":"User pasted an expired or mistyped share link; Instagram throttled anonymous requests and returned an interstitial; reqwest client built with .redirect(Policy::none()) so final_url never changes; share links from private/removed posts.","solutions":["Verify the share link opens in a normal browser and redirects to a /reel/ or /p/ URL.","Ensure the HTTP client follows redirects (reqwest::redirect::Policy::default() or limited N).","Retry with backoff — Instagram sometimes fails to redirect under rate limiting.","Ask the user for the full instagram.com/p/<id>/ or /reel/<id>/ URL instead of the share link."],"exampleFix":"// before\nlet final_url = response.url().to_string();\nif final_url.contains(\"/share/\") { return Err(anyhow!(\"Could not resolve share link\")); }\n// after\nlet final_url = response.url().to_string();\nif final_url.contains(\"/share/\") {\n    anyhow::bail!(\"Could not resolve share link {url} (expired, private, or redirects disabled)\");\n}\nlet shortcode = final_url.rsplit('/').find(|s| !s.is_empty())\n    .filter(|s| !s.is_empty()).context(\"share link resolved to bare domain\")?;","handlingStrategy":"validation","validationCode":"fn looks_like_share_link(url: &str) -> bool {\n    url.starts_with(\"https://www.instagram.com/share/\") && url.rsplit('/').find(|s| !s.is_empty()).map(|id| !id.is_empty()).unwrap_or(false)\n}\n// sanity-check the client follows redirects:\n// reqwest::Client::builder().redirect(reqwest::redirect::Policy::limited(10)).build()?","typeGuard":null,"tryCatchPattern":"match resolve_share_link(share_id).await {\n    Err(e) if e.to_string().contains(\"Could not resolve share link\") => {\n        // fall back to asking user for the canonical /p/ or /reel/ URL\n        Err(anyhow!(\"share link {share_id} did not redirect (expired or blocked); provide the full post URL\"))\n    }\n    other => other,\n}","preventionTips":["Configure the HTTP client to follow redirects (Policy::limited(10)).","Validate share IDs against user input before constructing the URL.","Treat share links as ephemeral — prefer canonical post URLs when available.","Back off and retry once; Instagram occasionally skips redirects under load."],"tags":["instagram","share-link","http-redirect","rust"],"backgroundTag":"invalid-url","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"}