{"record":{"id":"97bfa079f4c02429","repo":"astrid-runtime/astrid","slug":"winfsp-mountpoint-is-not-valid-utf-16","errorCode":null,"errorMessage":"WinFsp mountpoint is not valid UTF-16","messagePattern":"WinFsp mountpoint is not valid UTF-16","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/win.rs","lineNumber":210,"sourceCode":"    launch: StorageProviderServiceLaunchV1,\n    challenge: String,\n    runtime: Arc<tokio::runtime::Runtime>,\n) -> Result<()> {\n    if !parent_is_alive(&launch.parent) {\n        bail!(\"WinFsp service parent process is not alive\");\n    }\n    probe_callback(&launch).await?;\n    let listener = local_transport::bind(&launch.control_path).with_context(|| {\n        format!(\n            \"bind WinFsp service control {}\",\n            launch.control_path.display()\n        )\n    })?;\n    let callback = CallbackFs::new(launch.lease.clone(), runtime)\n        .map_err(|failure| anyhow::anyhow!(\"build WinFsp callback filesystem: {failure:?}\"))?;\n    initialize_winfsp()?;\n    let mountpoint = U16CString::from_os_str(launch.mountpoint.as_os_str())\n        .map_err(|_| anyhow::anyhow!(\"WinFsp mountpoint is not valid UTF-16\"))?;\n    let filesystem = FileSystem::start(\n        volume_params(launch.lease.access),\n        Some(&mountpoint),\n        callback,\n    )\n    .map_err(|status| anyhow::anyhow!(\"WinFsp failed to start private mount: {status:#x}\"))?;\n    let ready = StorageProviderServiceReadyV1 {\n        schema: STORAGE_FILESYSTEM_SERVICE_READY_SCHEMA_V1,\n        provider: crate::PROVIDER_NAME.to_owned(),\n        mount_id: launch.lease.mount_id.as_uuid(),\n        control_path: launch.control_path.clone(),\n        challenge,\n    };\n    let mut stdout = std::io::stdout().lock();\n    serde_json::to_writer(&mut stdout, &ready).context(\"encode WinFsp readiness\")?;\n    stdout\n        .write_all(b\"\\n\")\n        .context(\"terminate WinFsp readiness response\")?;","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/win.rs#L192-L228","documentation":"Raised in `run_private_service` (crates/astrid-storage-provider-winfsp/src/win.rs:210) when `U16CString::from_os_str` fails to convert the configured mountpoint path into a NUL-terminated UTF-16 string, which WinFsp requires. The error is thrown before `FileSystem::start` is invoked. It means the mountpoint `Path` contains characters that cannot be represented as UTF-16 (interior NUL bytes on Windows paths), so a valid Windows mountpoint string could not be built.","triggerScenarios":"Specifically: `U16CString::from_os_str(launch.mountpoint.as_os_str())` returns `Err`, i.e. `launch.mountpoint` contains an interior NUL byte or is otherwise not convertible to a UTF-16 C string. All normal Windows paths convert fine; only paths with embedded NULs fail.","commonSituations":"A mountpoint was built programmatically from raw bytes that include a NUL; a corrupted config file or IPC payload produced a mangled path; a caller passed a path constructed with `CString`-style data instead of normal OS path text.","solutions":["Check the mountpoint value passed to the WinFsp launch for embedded NUL bytes and remove them.","Validate the mountpoint path in the daemon/config layer before spawning the WinFsp service (e.g. reject paths whose OsStr encoding contains NUL).","Use a conventional mountpoint such as a drive designator (`X:`) or a normal directory path and retry.","Re-encode the path from its original text source rather than from raw bytes."],"exampleFix":"// before\nlet mountpoint = U16CString::from_os_str(launch.mountpoint.as_os_str())\n    .map_err(|_| anyhow::anyhow!(\"WinFsp mountpoint is not valid UTF-16\"))?;\n// after (validate earlier)\nif launch.mountpoint.as_os_str().to_str().map_or(true, |s| s.contains('\\0')) {\n    bail!(\"mountpoint contains NUL bytes: {:?}\", launch.mountpoint);\n}\nlet mountpoint = U16CString::from_os_str(launch.mountpoint.as_os_str())?;","handlingStrategy":"validation","validationCode":"fn mountpoint_is_utf16_safe(p: &Path) -> bool {\n    p.as_os_str().to_str().map_or(false, |s| !s.contains('\\0'))\n}\nassert!(mountpoint_is_utf16_safe(&PathBuf::from(\"Q:\\\\\")));","typeGuard":"fn valid_mountpoint(p: &std::path::Path) -> Option<&str> {\n    p.to_str().filter(|s| !s.contains('\\0'))\n}","tryCatchPattern":"let mountpoint = U16CString::from_os_str(launch.mountpoint.as_os_str())\n    .map_err(|_| anyhow::anyhow!(\n        \"WinFsp mountpoint {:?} is not valid UTF-16 (contains NUL?)\",\n        launch.mountpoint\n    ))?;","preventionTips":["Never build mountpoint paths from raw byte buffers; construct them from validated text.","Validate mountpoint strings for NUL bytes at config-parse time.","Prefer drive designators (`X:`) or normal directories as mountpoints."],"tags":["winfsp","utf-16","mountpoint","windows","path"],"backgroundTag":"invalid-argument-format","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"}