tonhowtf/omniget · error
Target domain is required for Cookie header import.
Error message
Target domain is required for Cookie header import.
What it means
parse_cookie_header() requires a target domain to scope the imported cookies (it builds '.{root}' as the cookie domain). An empty or whitespace-only domain (after trimming and stripping a leading dot) bails with this message.
Solutions
- Pass a non-empty target domain, e.g. parse_cookie_header(content, "bilibili.com").
- Validate/trim the domain input in the caller before invoking the parser.
- Use parse() for Netscape/JSON content, which does not need a domain.
Example fix
// before
parse_cookie_header("a=b", "")?;
// after
let domain = domain.trim();
anyhow::ensure!(!domain.is_empty(), "domain required");
parse_cookie_header("a=b", domain)?; Defensive patterns
Strategy: validation
Validate before calling
let domain = domain.trim().trim_start_matches('.');
anyhow::ensure!(!domain.is_empty(), "Target domain is required for Cookie header import."); Try / catch
match parsers::parse_for_domain(content, &domain) {
Err(e) if e.to_string().contains("Target domain is required") => prompt_for_domain(),
other => other,
} Prevention
- Always supply the site hostname when importing header-style cookies
- Validate the domain field in the UI before submitting
- Fall back to parse() for Netscape/JSON which need no domain
When it happens
Trigger: Calling parse_for_domain/parse_cookie_header with domain = "", " ", or "." so root becomes empty.
Common situations: UI passes an unset/blank domain field; config lookup for the domain returns empty string; caller forgets the domain argument when importing header-style cookies.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- invalid domain
- No valid cookies found in file (expected Netscape format)
- escolha a pasta de destino para organizar
- informe pelo menos um perfil de favoritos
- informe o blog
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/a227ff089b8bcba4.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/src/cookies/parsers.rs:98
};
let name = name.trim();
if name.is_empty() || value.is_empty() || !is_cookie_name(name) {
return false;
}
found += 1;
}
found > 0
}
fn is_cookie_name(name: &str) -> bool {
name.bytes()
.all(|b| b.is_ascii_alphanumeric() || matches!(b, b'_' | b'-' | b'.'))
}
pub fn parse_cookie_header(content: &str, domain: &str) -> anyhow::Result<Vec<ExtensionCookie>> {
let root = domain.trim().trim_start_matches('.').to_lowercase();
if root.is_empty() {
anyhow::bail!("Target domain is required for Cookie header import.");
}
let cookie_domain = format!(".{}", root);
let expires = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_secs() as i64)
.unwrap_or(0)
+ 60 * 60 * 24 * 3;
let body = content
.trim()
.strip_prefix("Cookie:")
.unwrap_or(content.trim());
let mut cookies = Vec::new();
for part in body.split(';') {
let p = part.trim();
if p.is_empty() {
continue;
}
let Some((name, value)) = p.split_once('=') else {View on GitHub (pinned to 8600b91f42)