{"record":{"id":"87f305dfa203826a","repo":"vercel/turborepo","slug":"invalid-sid-string-from-windows-e","errorCode":null,"errorMessage":"invalid SID string from Windows: {e}","messagePattern":"invalid SID string from Windows: (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/turborepo-daemon/src/endpoint.rs","lineNumber":400,"sourceCode":"    }\n\n    fn sid_to_string(sid: PSID) -> Result<String, std::io::Error> {\n        let mut string_sid = ptr::null_mut();\n        if unsafe { ConvertSidToStringSidW(sid, &mut string_sid) } == 0 {\n            return Err(std::io::Error::last_os_error());\n        }\n        let string_sid = LocalStringSid(string_sid);\n        let len = unsafe {\n            let mut len = 0;\n            while *string_sid.0.add(len) != 0 {\n                len += 1;\n            }\n            len\n        };\n        let slice = unsafe { std::slice::from_raw_parts(string_sid.0, len) };\n\n        String::from_utf16(slice).map_err(|e| {\n            std::io::Error::new(\n                std::io::ErrorKind::InvalidData,\n                format!(\"invalid SID string from Windows: {e}\"),\n            )\n        })\n    }\n\n    fn wide_null(value: &OsStr) -> Vec<u16> {\n        value.encode_wide().chain(std::iter::once(0)).collect()\n    }\n\n    struct Sid {\n        _buffer: Vec<usize>,\n        sid: PSID,\n    }\n\n    impl Sid {\n        fn as_ptr(&self) -> PSID {\n            self.sid","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-daemon/src/endpoint.rs#L382-L418","documentation":"sid_to_string (endpoint.rs:400 region) converts a SID with ConvertSidToStringSidW, walks the NUL-terminated wide string, and does String::from_utf16 on it. This InvalidData error means the SID string Windows returned was not valid UTF-16 (unpaired surrogates). ConvertSidToStringSidW only emits ASCII S-1-… strings, so this guards against corrupted output or memory trouble rather than any real SID state.","triggerScenarios":"No realistic input triggers it; it would require ConvertSidToStringSidW returning garbage — memory corruption, a broken security DLL, or an OS/API contract violation during daemon startup.","commonSituations":"Not observed in practice; if seen, suspect the process environment (injected DLLs, sandbox) rather than configuration","solutions":["Restart the machine / rerun the daemon once","Check for security software injecting into the process","If reproducible, capture a crash dump and file a bug — the guard exists to detect the impossible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// invariant guard: any occurrence is a bug — capture and report, do not retry\nErr(e) if e.kind() == std::io::ErrorKind::InvalidData && e.to_string().contains(\"SID string\") => {\n    capture_and_report(e); // includes path + os version\n}","preventionTips":["Treat this error as memory/environment corruption, not config","Avoid injecting DLLs into the turbo/daemon process"],"tags":["daemon","windows","sid","utf-16","invariant"],"backgroundTag":"sid-conversion-failed","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}