{"record":{"id":"bbe6056b84549b06","repo":"tonhowtf/omniget","slug":"invalid-domain-domain","errorCode":null,"errorMessage":"invalid domain: {domain}","messagePattern":"invalid domain: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/cookies/storage.rs","lineNumber":401,"sourceCode":"        .filter(|s| !s.is_empty())\n        .collect::<Vec<_>>()\n        .join(\"-\");\n    if collapsed.is_empty() || collapsed.starts_with('_') {\n        format!(\"account-{}\", current_unix_ms())\n    } else {\n        collapsed.chars().take(40).collect()\n    }\n}\n\npub fn ingest_to_account(\n    domain: &str,\n    requested_slug: &str,\n    cookies: &[ExtensionCookie],\n    source: IngestSource,\n) -> anyhow::Result<(String, usize)> {\n    let root = root_domain_of(domain);\n    if root.is_empty() {\n        anyhow::bail!(\"invalid domain: {domain}\");\n    }\n    let scoped: Vec<ExtensionCookie> = cookies\n        .iter()\n        .filter(|c| root_domain_of(&c.domain) == root)\n        .cloned()\n        .collect();\n    if scoped.is_empty() {\n        anyhow::bail!(\"no cookies in payload match domain {root}\");\n    }\n\n    let mut registry = load_registry();\n    let bucket = registry.buckets.entry(root.clone()).or_insert_with(|| {\n        let platform = PlatformKind::from_domain(&root);\n        BucketEntry {\n            platform_kind: platform.as_str().to_string(),\n            accounts: Vec::new(),\n        }\n    });","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/cookies/storage.rs#L383-L419","documentation":"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}'.","triggerScenarios":"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.","commonSituations":"Caller passes a full URL instead of a hostname; tests use 'localhost'; config supplies an empty domain field.","solutions":["Pass a valid registrable hostname, e.g. 'bilibili.com' or 'www.youtube.com'.","Strip scheme/path if you have a URL (use the URL's host component).","Validate the domain non-empty and contains a dot before calling."],"exampleFix":"// before\ningest_to_account(&root, \"https://example.com/profile\", slug, &cookies, src)?;\n// after\nlet host = url::Url::parse(\"https://example.com/profile\")?.host_str().unwrap().to_string();\ningest_to_account(&root, &host, slug, &cookies, src)?;","handlingStrategy":"validation","validationCode":"fn is_ingestable_domain(d: &str) -> bool {\n    let h = d.trim();\n    h.contains('.') && !h.contains(\"//\") && !h.parse::<std::net::IpAddr>().is_ok()\n}","typeGuard":null,"tryCatchPattern":"match ingest_to_account(root, domain, slug, &cookies, src) {\n    Err(e) if e.to_string().starts_with(\"invalid domain\") => reject_bad_domain_input(domain),\n    other => other,\n}","preventionTips":["Pass a bare hostname, never a URL or IP","Extract host via a URL parser when given full URLs","Reject 'localhost' and dotless hosts at input validation"],"tags":["cookies","domain","validation"],"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-15T23:17:13.987Z"}