{"record":{"id":"badffc8fe288ec2a","repo":"kovidgoyal/kitty","slug":"failed-to-copy-data-from-stdin-pipe-to-temp-file-w","errorCode":null,"errorMessage":"Failed to copy data from STDIN pipe to temp file with error: %w","messagePattern":"Failed to copy data from STDIN pipe to temp file with error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/clipboard/legacy.go","lineNumber":89,"sourceCode":"\tvar stdin_data []byte\n\tstdin_data, err = read_all_with_max_size(os.Stdin, 2*1024*1024)\n\tif err == nil {\n\t\tos.Stdin.Close()\n\t} else if err != ErrTooMuchPipedData {\n\t\tos.Stdin.Close()\n\t\terr = fmt.Errorf(\"Failed to read from STDIN pipe with error: %w\", err)\n\t\treturn\n\t}\n\tif err == ErrTooMuchPipedData {\n\t\ttempfile, err = utils.CreateAnonymousTemp(\"\")\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"Failed to create a temporary from STDIN pipe with error: %w\", err)\n\t\t}\n\t\ttempfile.Write(stdin_data)\n\t\t_, err = io.Copy(tempfile, os.Stdin)\n\t\tos.Stdin.Close()\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"Failed to copy data from STDIN pipe to temp file with error: %w\", err)\n\t\t}\n\t\ttempfile.Seek(0, io.SeekStart)\n\t\tdata_src = tempfile\n\t} else if stdin_data != nil {\n\t\tdata_src = bytes.NewBuffer(stdin_data)\n\t}\n\treturn\n}\n\nfunc run_plain_text_loop(opts *Options) (err error) {\n\tstdin_is_tty := tty.IsTerminal(os.Stdin.Fd())\n\tvar data_src io.Reader\n\tvar tempfile *os.File\n\tif !stdin_is_tty && !opts.GetClipboard {\n\t\t// we dont read STDIN when getting clipboard as it makes it hard to use the kitten in contexts where\n\t\t// the user does not control STDIN such as being execed from other programs.\n\t\tdata_src, tempfile, err = preread_stdin()\n\t\tif err != nil {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/clipboard/legacy.go#L71-L107","documentation":"After creating the spill temp file, remaining STDIN data is copied into it with io.Copy. If that copy fails (mid-stream write/read error), this error is returned. It means the pipe or the temp filesystem failed while transferring large clipboard data.","triggerScenarios":"Piping >2MB where the writer dies mid-copy (EPIPE) or the temp filesystem fills up during io.Copy.","commonSituations":"Upstream command killed by a signal mid-pipe; tmpfs disk-full while spilling large clipboard payloads.","solutions":["Verify the upstream pipeline command completes without being killed","Ensure the temp filesystem has space for the full payload","Re-run with a smaller payload to confirm the size threshold is the issue"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure temp fs has space: check syscall.Statfs on os.TempDir() before the transfer","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"copy data from STDIN\") { /* free space / smaller payload, then re-run */ }","preventionTips":["Ensure temp filesystem capacity exceeds the payload size","Prevent upstream producers from being killed mid-stream"],"tags":["kitty","clipboard","stdin","io-copy","disk-full"],"backgroundTag":"stream-copy-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}