{"record":{"id":"29df79dbf0935a13","repo":"tonhowtf/omniget","slug":"cole-o-link-de-um-post-do-reddit-ou-o-id-dele","errorCode":null,"errorMessage":"cole o link de um post do Reddit (ou o id dele)","messagePattern":"cole o link de um post do Reddit \\(ou o id dele\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/omniget-core/src/core/tools/reddit/thread.rs","lineNumber":800,"sourceCode":"\n#[derive(Debug, Clone, Serialize)]\npub struct ThreadResult {\n    pub title: String,\n    pub subreddit: String,\n    pub author: String,\n    pub permalink: String,\n    pub comments: usize,\n    pub missing: usize,\n    pub requests: u32,\n    pub files: Vec<String>,\n    pub dest: String,\n    /// Se o arquivamento saiu com a sessão do usuário ou anônimo.\n    pub used_session: bool,\n}\n\nasync fn resolve_post(fetcher: &Fetcher, url: &str) -> Result<(String, Option<String>)> {\n    let mut target = super::parse_target(url)\n        .ok_or_else(|| anyhow!(\"cole o link de um post do Reddit (ou o id dele)\"))?;\n    if let Target::Short { url } = &target {\n        let final_url = fetcher.resolve(url).await?;\n        target = super::parse_target(&final_url)\n            .ok_or_else(|| anyhow!(\"o link curto não levou a um post ({})\", final_url))?;\n    }\n    match target {\n        Target::Post { id, subreddit, .. } => Ok((id, subreddit)),\n        _ => Err(anyhow!(\n            \"isto não é um post: cole o link de uma thread (com /comments/ no meio)\"\n        )),\n    }\n}\n\n/// Abre os \"carregar mais\" até o teto de requisições. Devolve quantos\n/// comentários ficaram de fora.\nasync fn expand(\n    fetcher: &Fetcher,\n    post_id: &str,","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/reddit/thread.rs#L782-L818","documentation":"`resolve_post` first normalizes the user-supplied string via `parse_target`; if the input is neither a recognizable Reddit post URL nor a bare post id, this error is thrown before any network request. It is the input-validation guard for the thread archiving entry point.","triggerScenarios":"Calling run (which calls resolve_post) with an empty string, a comment/permalink/user/subreddit URL, a URL from another site, or any string that super::parse_target cannot classify as a post target — at src-tauri/omniget-core/src/core/tools/reddit/thread.rs:800.","commonSituations":"Users pasting a comment permalink instead of the post URL, pasting a subreddit or user link, typos/extra text around the URL, pasting a share link (resolved separately as Target::Short), or passing a bare id with surrounding whitespace/punctuation.","solutions":["Paste the full post permalink (e.g. https://reddit.com/r/sub/comments/<id>/...) or just the 6-7 character post id","Strip whitespace/markdown around the link before passing it","For share links (reddit.com/s/...), pass them as-is — they are resolved via fetcher.resolve, but the final URL must still be a post","If handling user input programmatically, pre-validate with super::parse_target and show a clearer prompt on None"],"exampleFix":"// before\nlet (id, _) = resolve_post(&fetcher, user_input).await?;\n// after\nif super::parse_target(user_input).is_none() {\n    anyhow::bail!(\"entrada inválida: '{}' não é um link de post nem um id\", user_input.trim());\n}\nlet (id, _) = resolve_post(&fetcher, user_input).await?;","handlingStrategy":"validation","validationCode":"fn is_probable_post_input(s: &str) -> bool {\n    let s = s.trim();\n    // bare id (6-8 alnum chars) or a /comments/ permalink\n    (s.len() >= 5 && s.len() <= 8 && s.chars().all(|c| c.is_ascii_alphanumeric()))\n        || s.contains(\"/comments/\")\n}","typeGuard":null,"tryCatchPattern":"match resolve_post(&fetcher, input).await {\n    Ok((id, title)) => /* ... */,\n    Err(e) if e.to_string().contains(\"cole o link\") => {\n        eprintln!(\"entrada '{}' não é um post: use o permalink /r/sub/comments/<id>/... ou o id\", input);\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Prompt users with the exact accepted formats: post permalink or bare post id","Trim and sanitize pasted input (strip markdown, quotes, whitespace)","Distinguish short/share links (Target::Short) which are auto-resolved from genuinely invalid input","Pre-validate with super::parse_target before making network calls to fail fast with a clear message"],"tags":["validation","input","reddit","invalid-url"],"backgroundTag":"invalid-url-format","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"}