tonhowtf/omniget · error
Invalid share code
Error message
Invalid share code: {} What it means
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.
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
Example fix
// before
let code = url.strip_prefix("p2p:")?;
downloader.get_media_info(&url).await?;
// after
let code = url.strip_prefix("p2p:").ok_or(anyhow!("Invalid P2P URL"))?.trim().to_lowercase();
anyhow::ensure!(words::is_valid_code(&code), "invalid share code: {}", code);
downloader.get_media_info(&format!("p2p:{}", code)).await?; Defensive patterns
Strategy: validation
Validate before calling
fn validate_share_code(url: &str) -> anyhow::Result<&str> {
let code = url.strip_prefix("p2p:").ok_or_else(|| anyhow!("not a p2p url"))?.trim();
anyhow::ensure!(words::is_valid_code(code), "invalid share code: {}", code);
Ok(code)
} Type guard
fn is_p2p_url(url: &str) -> bool {
url.strip_prefix("p2p:").map(|c| words::is_valid_code(c.trim())).unwrap_or(false)
} Try / catch
match get_media_info(&url).await {
Err(e) if format!("{e:#}").starts_with("Invalid share code") => {
ui.show_error("Please re-enter the share code exactly as shared");
}
other => other?,
} Prevention
- Paste, don't retype, share codes
- Trim and normalize casing before validation
- Include the wordlist version in shared codes
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/a40c3ed9e03dfddb.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/src/platforms/p2p/mod.rs:81
impl PlatformDownloader for P2pDownloader {
fn name(&self) -> &str {
"p2p"
}
fn can_handle(&self, url: &str) -> bool {
if let Some(code) = url.strip_prefix("p2p:") {
return words::is_valid_code(code);
}
false
}
async fn get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo> {
let code = url
.strip_prefix("p2p:")
.ok_or_else(|| anyhow!("Invalid P2P URL: {}", url))?;
if !words::is_valid_code(code) {
anyhow::bail!("Invalid share code: {}", code);
}
let title = format!("P2P Transfer ({})", &code[..code.len().min(30)]);
Ok(MediaInfo {
title,
author: "P2P Transfer".to_string(),
platform: "p2p".to_string(),
duration_seconds: None,
thumbnail_url: None,
available_qualities: vec![VideoQuality {
label: "Original".to_string(),
width: 0,
height: 0,
url: url.to_string(),
format: "p2p".to_string(),
}],
media_type: MediaType::Video,View on GitHub (pinned to 8600b91f42)