{"record":{"id":"5250b8684e9fac19","repo":"ytdl-org/youtube-dl","slug":"failed-to-write-string","errorCode":null,"errorMessage":"Failed to write string","messagePattern":"Failed to write string","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"youtube_dl/utils.py","lineNumber":3431,"sourceCode":"        return ((GetFileType(handle) & ~FILE_TYPE_REMOTE) != FILE_TYPE_CHAR\n                or GetConsoleMode(handle, ctypes.byref(ctypes.wintypes.DWORD())) == 0)\n\n    if not_a_console(h):\n        return False\n\n    def next_nonbmp_pos(s):\n        try:\n            return next(i for i, c in enumerate(s) if ord(c) > 0xffff)\n        except StopIteration:\n            return len(s)\n\n    while s:\n        count = min(next_nonbmp_pos(s), 1024)\n\n        ret = WriteConsoleW(\n            h, s, count if count else 2, ctypes.byref(written), None)\n        if ret == 0:\n            raise OSError('Failed to write string')\n        if not count:  # We just wrote a non-BMP character\n            assert written.value == 2\n            s = s[1:]\n        else:\n            assert written.value > 0\n            s = s[written.value:]\n    return True\n\n\ndef write_string(s, out=None, encoding=None):\n    if out is None:\n        out = sys.stderr\n    assert isinstance(s, compat_str)\n\n    if sys.platform == 'win32' and encoding is None and hasattr(out, 'fileno'):\n        if _windows_write_string(s, out):\n            return\n","sourceCodeStart":3413,"sourceCodeEnd":3449,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/utils.py#L3413-L3449","documentation":"Error \"Failed to write string\" thrown in ytdl-org/youtube-dl.","triggerScenarios":"Thrown at youtube_dl/utils.py:3431 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check write permissions and available disk space for the output location."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}