tonhowtf/omniget · error
Invalid P2P URL
Error message
Invalid P2P URL
What it means
download() validates that the MediaInfo it received carries a URL with the 'p2p:' scheme. If the stored/download URL lacks the prefix, it cannot extract the share code to open a relay connection. It is a defensive re-check of data built earlier by get_media_info.
Solutions
- Ensure the MediaInfo comes from p2p get_media_info so the url is 'p2p:<code>'
- Check the platform-dispatch logic so P2P downloads only handle p2p: URLs
- Validate the URL scheme before calling download
Example fix
// before
platform.download(opts).await?;
// after
if !opts.url.starts_with("p2p:") {
anyhow::bail!("expected p2p: URL, got {}", opts.url);
}
platform.download(opts).await?; Defensive patterns
Strategy: validation
Validate before calling
fn is_p2p_media(info: &MediaInfo) -> bool {
info.url.as_deref().map(|u| u.starts_with("p2p:")).unwrap_or(false)
} Try / catch
if !is_p2p_media(&info) {
return Err(anyhow!("MediaInfo is not a P2P transfer (missing p2p: URL)"));
}
platform.download(opts).await?; Prevention
- Only feed MediaInfo produced by the same platform's get_media_info into download
- Assert the p2p: scheme in tests that build MediaInfo fixtures
- Type-tag P2P media (e.g. enum MediaSource::P2p{code}) instead of free-form URLs
When it happens
Trigger: Calling download with a MediaInfo whose url field is not 'p2p:<code>' — e.g. MediaInfo constructed manually, or a URL from a different platform leaked into the P2P downloader.
Common situations: Hand-built MediaInfo objects in tests or integrations; platform routing bugs assigning non-P2P media to the P2P fetcher; URLs mutated/rewritten between get_media_info and download.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- Invalid P2P URL
- Invalid P2P URL
- Could not extract pin ID
- Invalid P2P URL
- os arquivos não tinham nenhuma escuta de música
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/5145820714522856.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/platforms/p2p.rs:115
media_type: MediaType::Video,
file_size_bytes: None,
})
}
async fn download(
&self,
info: &MediaInfo,
opts: &DownloadOptions,
progress: mpsc::Sender<ProgressUpdate>,
) -> anyhow::Result<DownloadResult> {
let url = match info.available_qualities.first() {
Some(q) => &q.url,
None => anyhow::bail!("No URL found in MediaInfo"),
};
let code = url
.strip_prefix("p2p:")
.ok_or_else(|| anyhow!("Invalid P2P URL"))?;
let _ = progress.send(ProgressUpdate::percent(-2.0)).await;
tracing::info!("[p2p] connecting to relay for code: {}", code);
let stream = connect_relay().await?;
let (read_half, mut write_half) = tokio::io::split(stream);
let mut reader = BufReader::new(read_half);
write_half
.write_all(format!("RECV {}\n", code).as_bytes())
.await?;
write_half.flush().await?;
let response = read_line(&mut reader).await?;
check_relay_error(&response)?;
if response != "READY" {
anyhow::bail!("Unexpected relay response: {}", response);View on GitHub (pinned to 8600b91f42)