{"record":{"id":"c08662eaec2fabac","repo":"tonhowtf/omniget","slug":"cookie-path-unavailable","errorCode":null,"errorMessage":"cookie path unavailable","messagePattern":"cookie path unavailable","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/bilibili/cookie.rs","lineNumber":203,"sourceCode":"    }\n    if !state.bili_ticket.is_empty() {\n        pairs.push(format!(\"bili_ticket={}\", state.bili_ticket));\n        pairs.push(format!(\"bili_ticket_expires={}\", state.bili_ticket_expires));\n    }\n    pairs.push(\"CURRENT_FNVAL=4048\".to_string());\n    pairs.push(\"CURRENT_QUALITY=0\".to_string());\n    pairs.join(\"; \")\n}\n\nfn seed_cookie_header(state: &AnonymousCookieState) -> String {\n    build_cookie_header(state)\n}\n\nfn write_netscape_for_anonymous(state: &AnonymousCookieState) -> std::io::Result<()> {\n    let path =\n        crate::platforms::cookie_provider::cookie_path_for_account(\"bilibili.com\", ANONYMOUS_SLUG)\n            .ok_or_else(|| {\n                std::io::Error::new(std::io::ErrorKind::Other, \"cookie path unavailable\")\n            })?;\n    if let Some(parent) = path.parent() {\n        std::fs::create_dir_all(parent)?;\n    }\n    let session_expires = now_secs() + 86400;\n    let expires = if state.bili_ticket_expires > 0 {\n        state.bili_ticket_expires\n    } else {\n        session_expires\n    };\n    let mut content = String::from(\"# Netscape HTTP Cookie File\\n\");\n    let pairs: Vec<(&str, String)> = vec![\n        (\"_uuid\", state.uuid.clone()),\n        (\"b_lsid\", state.b_lsid.clone()),\n        (\"b_nut\", state.b_nut.clone()),\n        (\"buvid_fp\", state.buvid_fp.clone()),\n        (\"buvid3\", state.buvid3.clone()),\n        (\"buvid4\", state.buvid4.clone()),","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/bilibili/cookie.rs#L185-L221","documentation":"write_netscape_for_anonymous in the omniget-core bilibili cookie module needs a filesystem path for the anonymous cookie file via cookie_path_for_account(\"bilibili.com\", ANONYMOUS_SLUG). That helper returns None when it cannot derive a valid path (typically because the app data directory is unavailable on this platform). The function converts that None into an io::Error with the message \"cookie path unavailable\" rather than panicking.","triggerScenarios":"ensure_fresh or bootstrap_anonymous calls write_netscape_for_anonymous while cookie_path_for_account returns None — i.e. the platform's app-data/data-local dir cannot be resolved (dirs crate returns None) or the account/slug components produce an invalid path.","commonSituations":"Running the Tauri app in a sandboxed or headless environment with no HOME/XDG_DATA_DIRS set; unusual OS packaging where tauri's path resolver fails; corrupt or misconfigured platform path resolution during CI test runs.","solutions":["Ensure the app data directory is resolvable: set HOME (Linux/macOS) or run in a normal user session so tauri/dirs can resolve app_data_dir.","Check cookie_path_for_account for why it returns None (path resolver failing vs invalid slug) and add logging before the error.","Initialize the cookie path eagerly at app startup (when the path resolver is guaranteed available) instead of lazily inside ensure_fresh.","In tests, use tauri::test or dependency-inject a known cookie directory instead of relying on the platform resolver."],"exampleFix":"// before\nlet path = crate::platforms::cookie_provider::cookie_path_for_account(\"bilibili.com\", ANONYMOUS_SLUG)\n    .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::Other, \"cookie path unavailable\"))?;\n\n// after\nlet path = crate::platforms::cookie_provider::cookie_path_for_account(\"bilibili.com\", ANONYMOUS_SLUG)\n    .or_else(|| std::env::var_os(\"HOME\").map(|h| std::path::PathBuf::from(h).join(\".local/share/omniget/cookies/bilibili.com-anonymous.cookies\")))\n    .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::Other, \"cookie path unavailable: app data dir could not be resolved\"))?;","handlingStrategy":"fallback","validationCode":"if crate::platforms::cookie_provider::cookie_path_for_account(\"bilibili.com\", ANONYMOUS_SLUG).is_none() {\n    // resolve fallback dir or disable anonymous cookie persistence\n}","typeGuard":null,"tryCatchPattern":"match write_netscape_for_anonymous(&state) {\n    Err(e) if e.to_string().contains(\"cookie path unavailable\") => {\n        tracing::warn!(\"no cookie dir; continuing without persistence\");\n    }\n    r => r?,\n}","preventionTips":["Verify the app data dir resolves at startup and log it once","Add a HOME/config-based fallback path","Do not call cookie persistence in environments without a writable data dir"],"tags":["filesystem","cookies","rust","app-data-dir"],"backgroundTag":"file-write-failed","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"}