{"record":{"id":"dadcb3d35745a472","repo":"microsoft/aspire","slug":"createfile-failed-with-error-error","errorCode":null,"errorMessage":"CreateFile failed with error {error}","messagePattern":"CreateFile failed with error (.+?)","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.CodeGeneration.Python/PythonModuleBuilder.cs","lineNumber":330,"sourceCode":"                ERROR_FILE_NOT_FOUND = 2\n\n                def __init__(self, pipe_path: str) -> None:\n                    self._handle: int | None = None\n                    handle = _kernel32.CreateFileW(\n                        pipe_path,\n                        self.GENERIC_READ | self.GENERIC_WRITE,\n                        0,  # no sharing\n                        None,  # default security\n                        self.OPEN_EXISTING,\n                        self.FILE_FLAG_OVERLAPPED,  # match server's async mode\n                        None  # no template\n                    )\n\n                    if handle == self.INVALID_HANDLE_VALUE:\n                        error = ctypes.get_last_error()\n                        if error == self.ERROR_FILE_NOT_FOUND:\n                            raise FileNotFoundError(f\"Pipe not found: {pipe_path}\")\n                        raise OSError(f\"CreateFile failed with error {error}\")\n\n                    self._handle = handle\n\n                def _create_overlapped_event(self) -> _OVERLAPPED:\n                    '''Create an OVERLAPPED structure with an event for async I/O.'''\n                    overlapped = _OVERLAPPED()\n                    overlapped.hEvent = _kernel32.CreateEventW(None, True, False, None)\n                    return overlapped\n\n                def recv(self, n: int) -> bytes:\n                    '''Read up to n bytes using overlapped I/O.'''\n                    buffer = ctypes.create_string_buffer(n)\n                    bytes_read = wintypes.DWORD()\n                    overlapped = self._create_overlapped_event()\n\n                    try:\n                        success = _kernel32.ReadFile(\n                            self._handle,","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.Python/PythonModuleBuilder.cs#L312-L348","documentation":"Raised when the Win32 CreateFile call used to open the Windows named pipe fails with an error other than ERROR_FILE_NOT_FOUND. It wraps the raw Win32 error code from ctypes.get_last_error(), indicating the pipe exists but could not be opened (access denied, pipe busy, invalid path, etc.).","triggerScenarios":"Opening a named pipe where the handle is INVALID_HANDLE_VALUE and GetLastError() is not ERROR_FILE_NOT_FOUND — e.g. ERROR_ACCESS_DENIED (ACLs/different user), ERROR_PIPE_BUSY (all instances in use), or ERROR_INVALID_NAME (malformed pipe path).","commonSituations":"Pipe created by a different user or elevated process (access denied); client hammering the pipe with no free instances; pipe path containing invalid characters or a typo in the \\\\.\\\\pipe\\\\ prefix.","solutions":["Decode the numeric error code (e.g. 5=ACCESS_DENIED, 231=PIPE_BUSY) to identify the cause.","If ERROR_PIPE_BUSY, retry after a short delay or have the host increase maximum pipe instances.","Fix pipe ACLs / run the client as the same user as the host if access is denied.","Validate the pipe path format (must be \\\\.\\pipe\\name)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    sock = _PipeSocket(pipe_path)\nexcept OSError as e:\n    code = e.winerror if hasattr(e, 'winerror') else None\n    log.error(\"pipe open failed (win32 code %s): %s\", code, e)\n    raise","preventionTips":["Run client and host as the same user to avoid pipe ACL denials.","Validate pipe path format before connecting.","Add retry-with-backoff for transient busy conditions."],"tags":["named-pipe","windows","win32","connection"],"backgroundTag":"connection-refused","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}