{"record":{"id":"1e3b66b1fcc9f53b","repo":"astrid-runtime/astrid","slug":"mountpoint-is-not-valid-utf-16","errorCode":null,"errorMessage":"mountpoint is not valid UTF-16","messagePattern":"mountpoint is not valid UTF-16","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/win.rs","lineNumber":81,"sourceCode":"        || !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| {\n            anyhow::anyhow!(\"WinFsp failed to start mount with status {status:#x}\")\n        })?;\n    wait_for_mountpoint_ready(&start.mountpoint)?;\n\n    let mut stdout = std::io::stdout().lock();\n    writeln!(stdout, \"READY {0}\", lease.mount_id).context(\"report WinFsp readiness\")?;\n    stdout.flush().context(\"flush WinFsp readiness\")?;\n\n    let result = runtime.block_on(daemon_loop(filesystem, control_listener));\n    if let Err(error) = result {\n        eprintln!(\"{PROVIDER_NAME}: daemon stopped after failure: {error:#}\");\n        return Err(error);\n    }\n    Ok(())\n}\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/win.rs#L63-L99","documentation":"The WinFsp daemon converts the mountpoint OsStr to a U16CString (UTF-16) as required by the WinFsp API. If the path cannot be represented as valid UTF-16, the daemon aborts with this error before starting the filesystem.","triggerScenarios":"Passing a mountpoint path containing invalid Unicode (unpaired surrogates from WTF-8 on Windows) — rare, but possible with paths built from raw bytes or unusual NTFS names.","commonSituations":"Programmatically constructed paths with invalid bytes; mountpoint sourced from untrusted config or environment containing surrogate code points; non-Unicode 16-bit path components.","solutions":["Use a mountpoint path with valid Unicode characters (ASCII drive-letter paths are safest)","Sanitize/validate the mountpoint path before spawning the daemon","Log the raw path bytes to identify the offending component","Avoid constructing paths from raw byte slices; use PathBuf from valid strings"],"exampleFix":"// before: opaque failure\nlet mountpoint = U16CString::from_os_str(start.mountpoint.as_os_str())\n    .map_err(|_| anyhow::anyhow!(\"mountpoint is not valid UTF-16\"))?;\n// after: include the path in the error\n.map_err(|_| anyhow::anyhow!(\"mountpoint is not valid UTF-16: {}\", start.mountpoint.display()))?;","handlingStrategy":"validation","validationCode":"// ensure the mountpoint string is valid Unicode before spawning the daemon\nlet s = start.mountpoint.to_str()\n    .ok_or_else(|| \"mountpoint path is not valid Unicode\")?;\nif s.chars().any(|c| (c as u32) >= 0xD800 && (c as u32) <= 0xDFFF) {\n    return Err(\"mountpoint contains surrogate code points\");\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"not valid UTF-16\") => {\n        // prompt user for a different mountpoint path\n    }\n    r => r,\n}","preventionTips":["Choose plain-Unicode (ideally ASCII) mountpoint paths","Never build paths from raw byte slices on Windows","Validate paths with Path::to_str before use","Sanitize mountpoints coming from config or env input"],"tags":["winfsp","windows","utf-16","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"}