tonhowtf/omniget · error
Could not resolve share link
Error message
Could not resolve share link
What it means
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.
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.
Example fix
// before
let final_url = response.url().to_string();
if final_url.contains("/share/") { return Err(anyhow!("Could not resolve share link")); }
// after
let final_url = response.url().to_string();
if final_url.contains("/share/") {
anyhow::bail!("Could not resolve share link {url} (expired, private, or redirects disabled)");
}
let shortcode = final_url.rsplit('/').find(|s| !s.is_empty())
.filter(|s| !s.is_empty()).context("share link resolved to bare domain")?; Defensive patterns
Strategy: validation
Validate before calling
fn looks_like_share_link(url: &str) -> bool {
url.starts_with("https://www.instagram.com/share/") && url.rsplit('/').find(|s| !s.is_empty()).map(|id| !id.is_empty()).unwrap_or(false)
}
// sanity-check the client follows redirects:
// reqwest::Client::builder().redirect(reqwest::redirect::Policy::limited(10)).build()? Try / catch
match resolve_share_link(share_id).await {
Err(e) if e.to_string().contains("Could not resolve share link") => {
// fall back to asking user for the canonical /p/ or /reel/ URL
Err(anyhow!("share link {share_id} did not redirect (expired or blocked); provide the full post URL"))
}
other => other,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- nao achei os arquivos JSON de seguidores no export. No…
- e.to_string()
- escolha pelo menos um arquivo
- e.to_string()
- tipo desconhecido
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/c19fc2d678d31e9c.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/platforms/instagram.rs:129
false
}
fn is_reel_url(url: &str) -> bool {
if let Ok(parsed) = url::Url::parse(url) {
let path = parsed.path().to_lowercase();
return path.starts_with("/reel/") || path.starts_with("/reels/");
}
false
}
async fn resolve_share_link(&self, share_id: &str) -> anyhow::Result<String> {
let url = format!("https://www.instagram.com/share/{}/", share_id);
let response = self.redirect_client.get(&url).send().await?;
let final_url = response.url().to_string();
if final_url.contains("/share/") || final_url == url {
return Err(anyhow!("Could not resolve share link"));
}
Ok(final_url)
}
fn regex_extract(pattern: &str, text: &str) -> Option<String> {
let re = Regex::new(pattern).ok()?;
re.captures(text)?.get(1).map(|m| m.as_str().to_string())
}
fn extract_object_entry(name: &str, html: &str) -> Option<serde_json::Value> {
let pattern = format!(r#"\["{}",.*?,(\{{.*?\}}),\d+\]"#, regex::escape(name));
let re = Regex::new(&pattern).ok()?;
let json_str = re.captures(html)?.get(1)?.as_str();
serde_json::from_str(json_str).ok()
}
fn extract_number_from_query(name: &str, html: &str) -> Option<String> {View on GitHub (pinned to 8600b91f42)