{"record":{"id":"dd2a13f97e29721a","repo":"kovidgoyal/kitty","slug":"failed-to-convert-src-path-to-rgba-data-with-err","errorCode":null,"errorMessage":"Failed to convert {src_path} to RGBA data with error: {cp.stderr.decode(\"utf-8\", \"replace\")}","messagePattern":"Failed to convert (.+?) to RGBA data with error: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"kitty/render_cache.py","lineNumber":76,"sourceCode":"            return 0.0\n\n        entries.sort(key=sort_key, reverse=True)\n        for e in entries[self.max_entries :]:\n            with suppress(FileNotFoundError):\n                os.remove(e.path)\n\n    def touch(self, path: str) -> None:\n        os.utime(path, follow_symlinks=False)\n\n    def render_image(self, src_path: str, output_path: str) -> None:\n        import stat\n        import subprocess\n\n        try:\n            with open(src_path, 'rb') as src, open(output_path, 'wb', opener=partial(os.open, mode=stat.S_IREAD | stat.S_IWRITE)) as output:\n                cp = subprocess.run([kitten_exe(), '__convert_image__', 'RGBA'], stdin=src, stdout=output, stderr=subprocess.PIPE)\n                if cp.returncode != 0:\n                    raise ValueError(f'Failed to convert {src_path} to RGBA data with error: {cp.stderr.decode(\"utf-8\", \"replace\")}')\n                if output.seek(0, os.SEEK_END) < 8:\n                    raise ValueError(f'Failed to convert {src_path} to RGBA data, no output written. stderr: {cp.stderr.decode(\"utf-8\", \"replace\")}')\n        except Exception:\n            with suppress(Exception):\n                os.unlink(output_path)\n            raise\n\n    def read_metadata(self, output_path: str) -> tuple[int, int, int]:\n        with open(output_path, 'rb') as f:\n            header = f.read(8)\n            import struct\n\n            width, height = struct.unpack('<II', header)\n            f.seek(0)\n            return width, height, os.dup(f.fileno())\n\n    def render(self, src_path: str) -> str:\n        import struct","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/render_cache.py#L58-L94","documentation":"Image rendering shells out to 'kitten __convert_image__ RGBA'; a non-zero exit code yields ValueError with the subprocess stderr. The source image could not be converted to raw RGBA.","triggerScenarios":"Passing a corrupt or unsupported image file (bad PNG/JPEG, zero-byte file, unsupported format) to the GPU/emoji render cache pipeline.","commonSituations":"Caching rendered images for hints/thumbnails when the input file is truncated, corrupt, or an exotic format.","solutions":["Verify the image opens in another tool; re-export it as PNG/JPEG","Check the embedded stderr in the message for the underlying decode error","Regenerate or re-download the source file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from PIL import Image\nwith Image.open(src_path) as im: im.verify()  # cheap sanity check","typeGuard":null,"tryCatchPattern":"except ValueError as e: log(e); skip/quarantine the image","preventionTips":["Verify images before feeding render cache","Watch stderr text embedded in the message for root cause"],"tags":["kitty","image","subprocess"],"backgroundTag":"image-decode-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}