tonhowtf/omniget · error

invalid domain

Error message

invalid domain: {domain}

What it means

ingest_to_account() derives the registrable root via root_domain_of(domain); if that returns empty (unparseable/empty domain such as 'localhost', an IP, or a bare TLD fragment), it bails with 'invalid domain: {domain}'.

Solutions

  1. Pass a valid registrable hostname, e.g. 'bilibili.com' or 'www.youtube.com'.
  2. Strip scheme/path if you have a URL (use the URL's host component).
  3. Validate the domain non-empty and contains a dot before calling.

Example fix

// before
ingest_to_account(&root, "https://example.com/profile", slug, &cookies, src)?;
// after
let host = url::Url::parse("https://example.com/profile")?.host_str().unwrap().to_string();
ingest_to_account(&root, &host, slug, &cookies, src)?;
Defensive patterns

Strategy: validation

Validate before calling

fn is_ingestable_domain(d: &str) -> bool {
    let h = d.trim();
    h.contains('.') && !h.contains("//") && !h.parse::<std::net::IpAddr>().is_ok()
}

Try / catch

match ingest_to_account(root, domain, slug, &cookies, src) {
    Err(e) if e.to_string().starts_with("invalid domain") => reject_bad_domain_input(domain),
    other => other,
}

Prevention

When it happens

Trigger: Calling ingest_to_account with domain values root_domain_of cannot reduce to a root: empty string, 'localhost', bare IP addresses, or malformed hosts like 'http://' remnants.

Common situations: Caller passes a full URL instead of a hostname; tests use 'localhost'; config supplies an empty domain field.

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


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/bbe6056b84549b06. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/cookies/storage.rs:401

        .filter(|s| !s.is_empty())
        .collect::<Vec<_>>()
        .join("-");
    if collapsed.is_empty() || collapsed.starts_with('_') {
        format!("account-{}", current_unix_ms())
    } else {
        collapsed.chars().take(40).collect()
    }
}

pub fn ingest_to_account(
    domain: &str,
    requested_slug: &str,
    cookies: &[ExtensionCookie],
    source: IngestSource,
) -> anyhow::Result<(String, usize)> {
    let root = root_domain_of(domain);
    if root.is_empty() {
        anyhow::bail!("invalid domain: {domain}");
    }
    let scoped: Vec<ExtensionCookie> = cookies
        .iter()
        .filter(|c| root_domain_of(&c.domain) == root)
        .cloned()
        .collect();
    if scoped.is_empty() {
        anyhow::bail!("no cookies in payload match domain {root}");
    }

    let mut registry = load_registry();
    let bucket = registry.buckets.entry(root.clone()).or_insert_with(|| {
        let platform = PlatformKind::from_domain(&root);
        BucketEntry {
            platform_kind: platform.as_str().to_string(),
            accounts: Vec::new(),
        }
    });

View on GitHub (pinned to 8600b91f42)