{"record":{"id":"565fb7160e5ff791","repo":"tonhowtf/omniget","slug":"invalid-share-code","errorCode":null,"errorMessage":"Invalid share code: {}","messagePattern":"Invalid share code: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/p2p.rs","lineNumber":79,"sourceCode":"impl PlatformDownloader for P2pDownloader {\n    fn name(&self) -> &str {\n        \"p2p\"\n    }\n\n    fn can_handle(&self, url: &str) -> bool {\n        if let Some(code) = url.strip_prefix(\"p2p:\") {\n            return super::p2p_words::is_valid_code(code);\n        }\n        false\n    }\n\n    async fn get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo> {\n        let code = url\n            .strip_prefix(\"p2p:\")\n            .ok_or_else(|| anyhow!(\"Invalid P2P URL: {}\", url))?;\n\n        if !super::p2p_words::is_valid_code(code) {\n            anyhow::bail!(\"Invalid share code: {}\", code);\n        }\n\n        let title = format!(\"P2P Transfer ({})\", &code[..code.len().min(30)]);\n\n        Ok(MediaInfo {\n            title,\n            author: \"P2P Transfer\".to_string(),\n            platform: \"p2p\".to_string(),\n            duration_seconds: None,\n            thumbnail_url: None,\n            available_qualities: vec![VideoQuality {\n                label: \"Original\".to_string(),\n                width: 0,\n                height: 0,\n                url: url.to_string(),\n                format: \"p2p\".to_string(),\n            }],\n            media_type: MediaType::Video,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/p2p.rs#L61-L97","documentation":"p2p.rs throws this in get_media_info() when the URL's share code fails super::p2p_words::is_valid_code(). The URL correctly uses the p2p: scheme (that check already passed), but the code itself is not a valid word-encoded share code, so the input is rejected before any relay contact.","triggerScenarios":"get_media_info(url) where url.strip_prefix(\"p2p:\") succeeds but p2p_words::is_valid_code(code) returns false at p2p.rs:79 — wrong word count, words outside the p2p_words dictionary, wrong casing/spacing, or stray characters in the code.","commonSituations":"User hand-types the share code and misspells a word; code truncated when copied; extra whitespace or punctuation included; a code from a different app/version using another word list; localizer autocorrects words.","solutions":["Re-enter the share code exactly as generated — check each word against the p2p_words list, casing and separators.","Copy-paste the full code instead of retyping it; ensure nothing was truncated at the ends.","Confirm the code was generated by the same app/protocol version (word lists can differ across versions).","Run is_valid_code(code) client-side before submitting the URL to give immediate feedback."],"exampleFix":"// before\nlet info = p2p.get_media_info(user_input).await?;\n// after\nlet code = user_input.strip_prefix(\"p2p:\").unwrap_or(&user_input);\nif !omniget_core::platforms::p2p_words::is_valid_code(code) {\n    return Err(anyhow!(\"'{}' is not a valid share code; re-check the words\", code));\n}\nlet info = p2p.get_media_info(user_input).await?;","handlingStrategy":"validation","validationCode":"// before calling get_media_info\nlet code = url.strip_prefix(\"p2p:\").ok_or_else(|| anyhow!(\"not a p2p: url\"))?;\nif !p2p_words::is_valid_code(code) {\n    eprintln!(\"invalid share code: {code}\");\n}","typeGuard":"// Rust\nfn valid_p2p_url(url: &str) -> Option<()> {\n    let code = url.strip_prefix(\"p2p:\")?;\n    if p2p_words::is_valid_code(code) { Some(()) } else { None }\n}","tryCatchPattern":"match p2p.get_media_info(url).await {\n    Err(e) if e.to_string().starts_with(\"Invalid share code\") => {\n        prompt_user_to_reenter_code();\n    }\n    other => other,\n}","preventionTips":["Copy-paste share codes instead of retyping","Trim whitespace and normalize separators from user input","Run is_valid_code in the UI for instant feedback","Regenerate the code if it came from a different protocol version"],"tags":["p2p","validation","share-code","input"],"backgroundTag":"invalid-identifier-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"}