kovidgoyal/kitty · warning · ErrTooMuchPipedData
Too much piped data
Error message
Too much piped data
What it means
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.
Source
Thrown at kittens/clipboard/legacy.go:44
if use_primary {
dest = "p"
}
return fmt.Sprintf("\x1b]52;%s;?\x1b\\", dest)
}
type base64_streaming_enc struct {
output func(string) loop.IdType
last_written_id loop.IdType
}
func (self *base64_streaming_enc) Write(p []byte) (int, error) {
if len(p) > 0 {
self.last_written_id = self.output(string(p))
}
return len(p), nil
}
var ErrTooMuchPipedData = errors.New("Too much piped data")
func read_all_with_max_size(r io.Reader, max_size int) ([]byte, error) {
b := make([]byte, 0, utils.Min(8192, max_size))
for {
if len(b) == cap(b) {
new_size := utils.Min(2*cap(b), max_size)
if new_size <= cap(b) {
return b, ErrTooMuchPipedData
}
b = append(make([]byte, 0, new_size), b...)
}
n, err := r.Read(b[len(b):cap(b)])
b = b[:len(b)+n]
if err != nil {
if err == io.EOF {
err = nil
}
return b, errView on GitHub (pinned to 6d5d0c4406)
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
Example fix
# before cat huge.log | kitten clipboard # error: Too much piped data # after head -c 76800 huge.log | kitten clipboard # or raise max size if configurable
Defensive patterns
Strategy: validation
Validate before calling
import os, sys MAX = 76800 # keep in sync with the kitten's limit size_ok = 0 <= (os.fstat(sys.stdin.fileno()).st_size if sys.stdin.isatty() is False and sys.stdin.seekable() else -1) <= MAX
Try / catch
// Go callers:
if err != nil {
if errors.Is(err, clipboard.ErrTooMuchPipedData) {
// skip or truncate input
}
} Prevention
- Check piped input size before feeding the kitten
- Split or truncate large streams
- Prefer passing files/paths over stdin for large payloads
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- Failed to read from STDIN pipe with error: %w
- Failed to copy data from STDIN pipe to temp file with error:
- Clipboard write request has more data than allowed by clipbo
- Too much data being sent
- Canceled by user
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/9b89dbd5cb43c9e7.
Report an issue: GitHub.