{"record":{"id":"4255ea734c8988c8","repo":"tonhowtf/omniget","slug":"o-link-curto-n-o-levou-a-um-post","errorCode":null,"errorMessage":"o link curto não levou a um post ({})","messagePattern":"o link curto não levou a um post \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/reddit/download.rs","lineNumber":544,"sourceCode":"    let r =\n        crate::core::tools::gallery::download(url, &dest.to_string_lossy(), None, progress.clone())\n            .await?;\n    Ok((r.files, r.log_tail))\n}\n\npub async fn run(opts: &Options, progress: ProgressFn) -> Result<DownloadResult> {\n    report(&progress, ID, \"started\", 0, None, None);\n    let dest = PathBuf::from(&opts.dest);\n    std::fs::create_dir_all(&dest)?;\n    let fetcher = Fetcher::new(opts.delay_ms, opts.session_netscape.as_deref())?;\n\n    let mut target = parse_target(&opts.url).ok_or_else(|| {\n        anyhow!(\"cole o link de um post do Reddit, de um i.redd.it ou de um v.redd.it\")\n    })?;\n    if let Target::Short { url } = &target {\n        let final_url = fetcher.resolve(url).await?;\n        target = parse_target(&final_url)\n            .ok_or_else(|| anyhow!(\"o link curto não levou a um post ({})\", final_url))?;\n    }\n\n    // Mídia solta e link de fora não têm post para consultar.\n    let (post, plan) = match &target {\n        Target::Post { id, .. } => {\n            let post = fetch_post(&fetcher, id).await?;\n            let plan = plan_for(&post);\n            (Some(post), plan)\n        }\n        Target::Media { url, video: true } => (None, Plan::Video { url: url.clone() }),\n        Target::Media { url, video: false } => (None, Plan::Image { url: url.clone() }),\n        Target::External { url } => (None, Plan::External { url: url.clone() }),\n        Target::Subreddit { .. } | Target::User { .. } => {\n            return Err(anyhow!(\n                \"isto é um sub ou um perfil: cole o link de um post\"\n            ))\n        }\n        Target::Short { .. } => return Err(anyhow!(\"não foi possível resolver o link curto\")),","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/reddit/download.rs#L526-L562","documentation":"The input was a short link (Target::Short); after fetcher.resolve() followed redirects, parse_target() still could not classify the final URL as a post or media target. The library throws this so the user knows the short link redirected to something unusable (the final URL is included in the message).","triggerScenarios":"A redd.it/<id> or reddit.com/s/<token> style short URL whose redirect lands on a subreddit page, a login/consent page, an external site, or fails to a URL parse_target doesn't recognize.","commonSituations":"Deleted/removed posts whose short links redirect to the subreddit; region/NSFW consent interstitials; link shorteners wrapping a non-Reddit destination; rate-limit or error pages served to the resolver.","solutions":["Open the short link in a browser, copy the full post URL it redirects to, and pass that instead","Verify the post still exists and is not removed/quarantined (consent pages break resolution)","Re-run with a valid session cookie via opts.session_netscape if Reddit is serving a consent/login redirect","If the link truly points to media, paste the direct i.redd.it / v.redd.it URL instead"],"exampleFix":"// before\nurl: \"https://redd.it/abc123\"  // redirects to removed post\n// after\nurl: \"https://www.reddit.com/r/rust/comments/abc123/title/\"","handlingStrategy":"fallback","validationCode":"// Pre-check short links by following them with an HTTP client:\nlet resp = reqwest::Client::new().get(&short_url).send().await?;\nlet final_url = resp.url().to_string();\nif !final_url.contains(\"/comments/\") { eprintln!(\"short link did not lead to a post: {}\", final_url); }","typeGuard":null,"tryCatchPattern":"match tool.run(opts).await {\n    Err(e) if e.to_string().starts_with(\"o link curto\") => {\n        // expand the link manually or ask user for the full post URL\n    }\n    other => other?,\n}","preventionTips":["Resolve redd.it short links in a browser first and use the full /comments/ URL","Provide session_netscape cookies to survive consent/login redirects","Avoid short links for deleted or quarantined posts","Log the final URL on failure — the error already includes it for diagnosis"],"tags":["reddit","redirect","url-resolution"],"backgroundTag":"resource-not-found","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"}