{"record":{"id":"098011e090784f53","repo":"tonhowtf/omniget","slug":"invalid-p2p-url","errorCode":null,"errorMessage":"Invalid P2P URL: {}","messagePattern":"Invalid P2P URL: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/p2p.rs","lineNumber":76,"sourceCode":"}\n\n#[async_trait]\nimpl 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(),","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/p2p.rs#L58-L94","documentation":"get_media_info() requires URLs with the 'p2p:' scheme; any URL lacking this prefix is rejected. The scheme is the library's marker that a URL refers to a P2P share-code transfer. This is a strict input-format guard before the share code is validated.","triggerScenarios":"Calling get_media_info with a URL that does not start with 'p2p:' (e.g. a plain https URL, empty string, or a mistyped scheme like 'p2p//code').","commonSituations":"Passing a normal HTTP media URL into the P2P platform handler; user pastes code without the 'p2p:' prefix; upstream code that selects the wrong platform for a URL.","solutions":["Prefix the share code with 'p2p:' before calling get_media_info","Route the URL to the correct platform handler if it is not a P2P transfer","Trim whitespace/normalize the URL scheme before dispatching"],"exampleFix":"// before\nplatform.get_media_info(\"abcdef123\").await?;\n// after\nplatform.get_media_info(\"p2p:abcdef123\").await?;","handlingStrategy":"validation","validationCode":"fn ensure_p2p_url(url: &str) -> Result<(), String> {\n    if url.trim().starts_with(\"p2p:\") { Ok(()) } else { Err(format!(\"URL must start with p2p:, got: {url}\")) }\n}","typeGuard":null,"tryCatchPattern":"match platform.get_media_info(url).await {\n    Err(e) if e.to_string().contains(\"Invalid P2P URL\") => {\n        eprintln!(\"Pass a 'p2p:<code>' URL, not: {url}\");\n    }\n    other => other?,\n}","preventionTips":["Normalize/trim user input before dispatching to a platform handler","Route URLs by scheme so p2p: URLs only reach the P2P platform","Document the p2p: prefix requirement in user-facing help text"],"tags":["url","p2p","input-validation","argument-format"],"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-16T04:17:20.429Z"}