{"record":{"id":"7335124fb64546cc","repo":"kovidgoyal/kitty","slug":"failed-to-read-image-data-output-file-s-with-err","errorCode":null,"errorMessage":"Failed to read image data output file: %s with error: %w","messagePattern":"Failed to read image data output file: (.+?) with error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/icat/transmit.go","lineNumber":161,"sourceCode":"\t\t\tos.Remove(f.Name())\n\t\t\treturn fmt.Errorf(\"Failed to write image data to temp file for transmission: %w\", err)\n\t\t}\n\t\tfname = f.Name()\n\t}\n\tgc := gc_for_image(imgd, frame_num, frame)\n\tgc.SetTransmission(utils.IfElse(is_temp, graphics.GRT_transmission_tempfile, graphics.GRT_transmission_file))\n\tif data_size > 0 {\n\t\tgc.SetDataSize(uint64(data_size))\n\t}\n\treturn gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(fname))\n}\n\nfunc transmit_stream(imgd *image_data, frame_num int, frame *image_frame) (err error) {\n\tdata := frame.in_memory_bytes\n\tif data == nil {\n\t\tdata, err = os.ReadFile(frame.filename)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to read image data output file: %s with error: %w\", frame.filename, err)\n\t\t}\n\t}\n\tgc := gc_for_image(imgd, frame_num, frame)\n\treturn gc.WriteWithPayloadTo(os.Stdout, data)\n}\n\nfunc calculate_in_cell_x_offset(width, cell_width int) int {\n\textra_pixels := width % cell_width\n\tif extra_pixels == 0 {\n\t\treturn 0\n\t}\n\tswitch opts.Align {\n\tcase \"left\":\n\t\treturn 0\n\tcase \"right\":\n\t\treturn cell_width - extra_pixels\n\tdefault:\n\t\treturn (cell_width - extra_pixels) / 2","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/icat/transmit.go#L143-L179","documentation":"Raised by transmit_stream in the icat kitten when the frame's image file must be read from disk (no in-memory bytes exist) and os.ReadFile fails. This happens when the cached/processed image output file was deleted or became unreadable between processing and transmission.","triggerScenarios":"Running icat in stream mode where frame.in_memory_bytes is nil and frame.filename no longer exists or is not readable. Commonly a race where a cache file was cleaned up, or permissions changed while the kitten ran.","commonSituations":"Cache directories cleaned mid-run, NFS/tmp-reaper (systemd-tmpfiles) removing files, running icat over a file on an unmounted/rotated network share.","solutions":["Re-run icat on the original image file directly","Check that the kitty cache directory is not being pruned by tmp cleaners; exclude it from systemd-tmpfiles","Verify read permissions on the file shown in the error message","Avoid pointing kitty cache at volatile storage like /tmp with aggressive cleanup"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, err := os.Stat(frameFilename); err != nil {\n    // re-generate the image file before transmission\n}","typeGuard":null,"tryCatchPattern":"if err := transmit(); err != nil {\n    if strings.Contains(err.Error(), \"Failed to read image data\") {\n        regenerateImage() // then retry once\n    }\n}","preventionTips":["Exclude kitty cache dirs from tmp cleaners","Avoid caching on volatile storage"],"tags":["icat","file-read","cache-eviction","kitty"],"backgroundTag":"file-read-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}