{"record":{"id":"9b89dbd5cb43c9e7","repo":"kovidgoyal/kitty","slug":"too-much-piped-data","errorCode":null,"errorMessage":"Too much piped data","messagePattern":"Too much piped data","errorType":"error_code","errorClass":"ErrTooMuchPipedData","httpStatus":null,"severity":"warning","filePath":"kittens/clipboard/legacy.go","lineNumber":44,"sourceCode":"\tif use_primary {\n\t\tdest = \"p\"\n\t}\n\treturn fmt.Sprintf(\"\\x1b]52;%s;?\\x1b\\\\\", dest)\n}\n\ntype base64_streaming_enc struct {\n\toutput          func(string) loop.IdType\n\tlast_written_id loop.IdType\n}\n\nfunc (self *base64_streaming_enc) Write(p []byte) (int, error) {\n\tif len(p) > 0 {\n\t\tself.last_written_id = self.output(string(p))\n\t}\n\treturn len(p), nil\n}\n\nvar ErrTooMuchPipedData = errors.New(\"Too much piped data\")\n\nfunc read_all_with_max_size(r io.Reader, max_size int) ([]byte, error) {\n\tb := make([]byte, 0, utils.Min(8192, max_size))\n\tfor {\n\t\tif len(b) == cap(b) {\n\t\t\tnew_size := utils.Min(2*cap(b), max_size)\n\t\t\tif new_size <= cap(b) {\n\t\t\t\treturn b, ErrTooMuchPipedData\n\t\t\t}\n\t\t\tb = append(make([]byte, 0, new_size), b...)\n\t\t}\n\t\tn, err := r.Read(b[len(b):cap(b)])\n\t\tb = b[:len(b)+n]\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\terr = nil\n\t\t\t}\n\t\t\treturn b, err","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/clipboard/legacy.go#L26-L62","documentation":"ErrTooMuchPipedData is returned by read_all_with_max_size (and preread_stdin) in the clipboard kitten's Go code when the data piped into the kitten on stdin exceeds the configured maximum size. The reader grows its buffer up to max_size; once capacity would have to exceed the limit it stops and returns this sentinel error instead of buffering unbounded input.","triggerScenarios":"Piping large data into the clipboard kitten, e.g. `cat hugefile | kitten clipboard` or `some-cmd | kitten clipboard copy`, where the accumulated bytes exceed max_size (default cap on piped input). Callers like preread_stdin propagate it and the kitten exits with 'Too much piped data'.","commonSituations":"Piping multi-megabyte files, logs, or binary blobs into the kitten; generating output that grew past the cap after a script change; using the kitten as a generic sink for large pipeline output.","solutions":["Reduce the piped data below the size limit (trim, filter, or split the input)","Pass the data by path/argument instead of stdin if the kitten supports it, so no pipe cap applies","Copy the large content with a different tool (e.g. files/transfer protocols) rather than through the terminal clipboard"],"exampleFix":"# before\ncat huge.log | kitten clipboard   # error: Too much piped data\n\n# after\nhead -c 76800 huge.log | kitten clipboard   # or raise max size if configurable","handlingStrategy":"validation","validationCode":"import os, sys\nMAX = 76800  # keep in sync with the kitten's limit\nsize_ok = 0 <= (os.fstat(sys.stdin.fileno()).st_size if sys.stdin.isatty() is False and sys.stdin.seekable() else -1) <= MAX","typeGuard":null,"tryCatchPattern":"// Go callers:\nif err != nil {\n    if errors.Is(err, clipboard.ErrTooMuchPipedData) {\n        // skip or truncate input\n    }\n}","preventionTips":["Check piped input size before feeding the kitten","Split or truncate large streams","Prefer passing files/paths over stdin for large payloads"],"tags":["kitty","clipboard","stdin","size-limit","go"],"backgroundTag":"stdin-input-size-limit","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}