{"record":{"id":"afacb1e2c05093c2","repo":"astrid-runtime/astrid","slug":"winfsp-daemon-lease-contains-a-relative-endpoint","errorCode":null,"errorMessage":"WinFsp daemon lease contains a relative endpoint","messagePattern":"WinFsp daemon lease contains a relative endpoint","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/win.rs","lineNumber":65,"sourceCode":"}\n\npub(crate) fn daemon_main() -> Result<()> {\n    let mut bytes = Vec::new();\n    std::io::stdin()\n        .lock()\n        .take(MAX_LEASE_BYTES + 1)\n        .read_to_end(&mut bytes)\n        .context(\"read WinFsp daemon lease\")?;\n    if bytes.len() as u64 > MAX_LEASE_BYTES {\n        bail!(\"WinFsp daemon lease exceeds limit\");\n    }\n    let start: DaemonStart =\n        serde_json::from_slice(&bytes).context(\"decode WinFsp daemon lease\")?;\n    let lease = start.lease;\n    if (!start.mountpoint.is_absolute() && !is_drive_designator(&start.mountpoint))\n        || !lease.callback_path.is_absolute()\n    {\n        bail!(\"WinFsp daemon lease contains a relative endpoint\");\n    }\n\n    let runtime = Arc::new(\n        tokio::runtime::Builder::new_multi_thread()\n            .enable_all()\n            .build()\n            .context(\"start WinFsp callback runtime\")?,\n    );\n    let callback = CallbackFs::new(lease.clone(), Arc::clone(&runtime))\n        .map_err(|failure| anyhow::anyhow!(\"build WinFsp callback filesystem: {failure:?}\"))?;\n    let control_path = provider_control_path(&lease.mount_id)?;\n    let control_listener = local_transport::bind(&control_path)\n        .with_context(|| format!(\"bind WinFsp control endpoint {}\", control_path.display()))?;\n    initialize_winfsp()?;\n    let mountpoint = U16CString::from_os_str(start.mountpoint.as_os_str())\n        .map_err(|_| anyhow::anyhow!(\"mountpoint is not valid UTF-16\"))?;\n    let filesystem = FileSystem::start(volume_params(lease.access), Some(&mountpoint), callback)\n        .map_err(|status| {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/win.rs#L47-L83","documentation":"After decoding the daemon start document, daemon_main validates that the mountpoint is either absolute or a drive designator (e.g. 'X:'), and that lease.callback_path is absolute. If either is relative, the daemon bails because relative paths in a spawned daemon would resolve against an unpredictable working directory.","triggerScenarios":"Launching the WinFsp daemon with a relative mountpoint string that is not a drive designator (e.g. 'mounts/astrid'), or a lease whose callback_path was built without absolutization (e.g. from a relative CLI flag or config value).","commonSituations":"Passing a relative path from a config file or --mount flag; a Windows service or scheduled task starting the daemon with a different CWD than the parent assumed; constructing callback_path with std::env::current_dir() skipped.","solutions":["Pass an absolute mountpoint path or a drive designator like 'X:' (a drive letter with colon is accepted)","Absolutize callback_path before writing the lease (std::fs::canonicalize or joining with a known base dir)","In the launcher, reject/normalize relative paths at config parse time with context about the CWD used"],"exampleFix":"// before\nDaemonStart { mountpoint: PathBuf::from(\"mounts/astrid\"), .. }\n// after\nDaemonStart { mountpoint: PathBuf::from(\"C:\\\\mounts\\\\astrid\"), .. } // or canonicalize() the input","handlingStrategy":"validation","validationCode":"if !mountpoint.is_absolute() && !is_drive_designator(&mountpoint) {\n    return Err(format!(\"mountpoint must be absolute or a drive designator: {}\", mountpoint.display()));\n}\nif !callback_path.is_absolute() {\n    return Err(format!(\"callback_path must be absolute: {}\", callback_path.display()));\n}","typeGuard":"fn is_absolute_or_drive(p: &Path) -> bool {\n    p.is_absolute() || p.to_str().map(is_drive_designator).unwrap_or(false)\n}","tryCatchPattern":"match daemon_err {\n    Err(e) if e.to_string().contains(\"relative endpoint\") => {\n        eprintln!(\"absolutize mountpoint/callback_path before launch\");\n    }\n    other => other?,\n}","preventionTips":["Canonicalize all paths at config-parse time","Never pass user-supplied relative paths straight into DaemonStart","Remember drive designators like 'X:' count as absolute here"],"tags":["windows","winfsp","paths","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}