{"record":{"id":"a40c3ed9e03dfddb","repo":"tonhowtf/omniget","slug":"invalid-share-code-mod","errorCode":null,"errorMessage":"Invalid share code: {}","messagePattern":"Invalid share code: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/platforms/p2p/mod.rs","lineNumber":81,"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 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 !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":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/platforms/p2p/mod.rs#L63-L99","documentation":"get_media_info expects a URL of the form 'p2p:<share-code>' where the code must pass words::is_valid_code (a word-based code scheme). If the code is malformed or not from the expected wordlist, it bails with this error including the offending code.","triggerScenarios":"Calling get_media_info with a p2p: URL whose suffix fails words::is_valid_code — typo, wrong number of words, words outside the wordlist, wrong casing/whitespace, or truncated code.","commonSituations":"User hand-types a share code instead of pasting; code copied with trailing spaces or case changes; a code generated by an incompatible app version using a different wordlist.","solutions":["Check the code embedded in the error for typos, casing, or extra whitespace","Regenerate/re-share the code from the sender so it comes from the same wordlist","Normalize input before validation: trim, lowercase, and re-join words consistently","Confirm both peers use the same words wordlist/version"],"exampleFix":"// before\nlet code = url.strip_prefix(\"p2p:\")?;\ndownloader.get_media_info(&url).await?;\n// after\nlet code = url.strip_prefix(\"p2p:\").ok_or(anyhow!(\"Invalid P2P URL\"))?.trim().to_lowercase();\nanyhow::ensure!(words::is_valid_code(&code), \"invalid share code: {}\", code);\ndownloader.get_media_info(&format!(\"p2p:{}\", code)).await?;","handlingStrategy":"validation","validationCode":"fn validate_share_code(url: &str) -> anyhow::Result<&str> {\n    let code = url.strip_prefix(\"p2p:\").ok_or_else(|| anyhow!(\"not a p2p url\"))?.trim();\n    anyhow::ensure!(words::is_valid_code(code), \"invalid share code: {}\", code);\n    Ok(code)\n}","typeGuard":"fn is_p2p_url(url: &str) -> bool {\n    url.strip_prefix(\"p2p:\").map(|c| words::is_valid_code(c.trim())).unwrap_or(false)\n}","tryCatchPattern":"match get_media_info(&url).await {\n    Err(e) if format!(\"{e:#}\").starts_with(\"Invalid share code\") => {\n        ui.show_error(\"Please re-enter the share code exactly as shared\");\n    }\n    other => other?,\n}","preventionTips":["Paste, don't retype, share codes","Trim and normalize casing before validation","Include the wordlist version in shared codes"],"tags":["validation","p2p","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"}