tonhowtf/omniget · error
Could not extract post ID from Threads URL
Error message
Could not extract post ID from Threads URL
What it means
get_media_info in threads.rs calls Self::extract_post_id(url) and uses ok_or_else to raise this error when the URL does not yield a post ID. It is an input validation failure: the supplied URL is not a Threads post URL the regex/pattern recognizes.
Solutions
- Ensure the URL is a full Threads post URL containing a post ID
- Add the missing URL shape (e.g. /t/ share links or threads.net domain) to extract_post_id
- Normalize the URL (strip query params, map domains) before calling
- Validate the URL client-side and reject non-post links with a clear message
Example fix
// before
Err(anyhow!("Could not extract post ID from Threads URL"))
// after
Err(anyhow!("Could not extract post ID from Threads URL: {}", url)) Defensive patterns
Strategy: validation
Validate before calling
const THREADS_POST_RE = /^https:\/\/(www\.)?threads\.((com)|(net))\/@[\w.]+\/(post|t)\/([\w-]+)/;
if (!THREADS_POST_RE.test(url)) throw new Error("Not a Threads post URL"); Type guard
function isThreadsPostUrl(url) {
try { return THREADS_POST_RE.test(new URL(url).href); } catch { return false; }
} Try / catch
match threads.get_media_info(url).await {
Err(e) if e.to_string().contains("Could not extract post ID") => {
return Err(UserInputError::new("Please paste a direct Threads post link"));
}
other => other?,
} Prevention
- Normalize domains (threads.net -> threads.com) and strip query strings before calling
- Support all known share-link shapes (/t/, /post/) in your own pre-validation
- Reject clearly non-post URLs in the UI before hitting the library
- Keep the post-ID pattern in sync with extract_post_id
When it happens
Trigger: Calling get_media_info with a URL that is not a Threads post link — a profile URL, a share link with an unexpected shape, a truncated URL, or a link to another platform.
Common situations: Users pasting threads.com/thread/... variants (threads.net vs threads.com domains), share links (threads.com/t/...) the extractor misses, or URLs with extra query/fragment parts breaking the pattern.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- nao reconheci um video do YouTube em
- não reconheci esse perfil ou coleção
- Could not extract clip slug
- Could not extract post ID
- Could not extract YouTube video ID
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/9b30cf9cd63ba200.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/platforms/threads.rs:383
"threads"
}
fn can_handle(&self, url: &str) -> bool {
if let Ok(parsed) = url::Url::parse(url) {
if let Some(host) = parsed.host_str() {
let host = host.to_lowercase();
return host == "threads.net"
|| host.ends_with(".threads.net")
|| host == "threads.com"
|| host.ends_with(".threads.com");
}
}
false
}
async fn get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo> {
let post_id = Self::extract_post_id(url)
.ok_or_else(|| anyhow!("Could not extract post ID from Threads URL"))?;
let filename_base = format!("threads_{}", post_id);
// Fetch della pagina e ricerca del post nel JSON bootstrap
let post = self.fetch_post(url, &post_id).await?;
// Per post share/repost il media vive in un contenitore annidato
let container = Self::resolve_media_container(&post);
let thumbnail_url = Self::best_thumbnail(container);
// Estrai metadata
let (uploader, _timestamp) = Self::extract_metadata(&post);
// Estrai media
let media = Self::extract_media_from_post(container)?;
match media {
ThreadsMedia::Single {View on GitHub (pinned to 8600b91f42)