{"record":{"id":"c83ffdbd81ee3843","repo":"junegunn/fzf","slug":"not-a-valid-number-str","errorCode":null,"errorMessage":"not a valid number: ${str}","messagePattern":"not a valid number: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/options.go","lineNumber":835,"sourceCode":"}\n\nfunc isDir(path string) bool {\n\tstat, err := os.Stat(path)\n\treturn err == nil && stat.IsDir()\n}\n\nfunc atoi(str string) (int, error) {\n\tnum, err := strconv.Atoi(str)\n\tif err != nil {\n\t\treturn 0, errors.New(\"not a valid integer: \" + str)\n\t}\n\treturn num, nil\n}\n\nfunc atof(str string) (float64, error) {\n\tnum, err := strconv.ParseFloat(str, 64)\n\tif err != nil {\n\t\treturn 0, errors.New(\"not a valid number: \" + str)\n\t}\n\treturn num, nil\n}\n\nfunc splitNth(str string) ([]Range, error) {\n\tif match, _ := regexp.MatchString(\"^[0-9,-.]+$\", str); !match {\n\t\treturn nil, errors.New(\"invalid format: \" + str)\n\t}\n\n\ttokens := strings.Split(str, \",\")\n\tranges := make([]Range, len(tokens))\n\tfor idx, s := range tokens {\n\t\tr, ok := ParseRange(&s)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"invalid format: \" + str)\n\t\t}\n\t\tranges[idx] = r\n\t}","sourceCodeStart":817,"sourceCodeEnd":853,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/options.go#L817-L853","documentation":"Returned by LightRenderer.getBytesInternal (src/tui/light.go:387) when the input read loop accumulates more than maxInputBuffer (1 MiB, src/tui/light.go:28) bytes without an idle gap. The renderer reads terminal bytes in a tight non-blocking loop (assembling escape sequences and bracketed paste); the overflow check fires only when bytes keep arriving back-to-back, so fzf terminates immediately rather than allocating unbounded memory. The error is fatal: the renderer is closed and a Fatal event propagates.","triggerScenarios":"A single burst of uninterrupted terminal input exceeding 1 MiB: pasting (or having a tool write) an extremely large block into the fzf TTY, especially with bracketed-paste escape wrappers; a misbehaving program or script (`cat hugefile > $(tty)`, a runaway loop writing to the terminal, a tmux/screen pane flooding output) feeding continuous bytes so the loop never sees an idle poll; terminal emulators replaying huge scrollback or macros. Normal typing and ordinary pastes never reach 1 MiB in one gapless burst.","commonSituations":"Pasting an entire minified JS bundle or a huge JSON file into fzf's query line instead of feeding it on stdin; shell scripts that `echo`/`printf` megabytes into the tty where fzf is running; a key-repeating macro or stuck key bridged by a terminal multiplexer; CI harnesses driving fzf's tty with oversized synthetic input; latency spikes on slow links that batch >1 MiB of input into one readable chunk.","solutions":["Feed large data to fzf on stdin (the candidate list) instead of pasting it into the query line: `huge_file | fzf` or `fzf < query.txt`.","Find and stop the process flooding the tty: check for runaway writers to the terminal (`ps aux | grep -E 'cat|echo'`, multiplexer panes) and re-run fzf in a clean terminal.","Keep pastes under ~1 MiB or disable bracketed paste in your terminal emulator if it wraps giant pastes into one uninterrupted escape sequence.","If you drive fzf programmatically via its tty, write input in chunks with small pauses (>= escPollInterval-scale gaps) so the read loop can flush the buffer between bursts.","If a specific large paste legitimately must be searched, put it in a file and use fzf's file input rather than the interactive query."],"exampleFix":"# before (pasting a 2 MB block into the query line -> fatal overflow)\n#   fzf\n<paste of huge.txt>\n\n# after (data on stdin, query stays tiny)\ncat huge.txt | fzf\n# or preload the initial query from a file within size limits:\ncat huge.txt | fzf --query=\"$(head -c 1000 query.txt)\"","handlingStrategy":"validation","validationCode":"// Shell wrapper: gate pastes/programmatic query injection by size\nmax_query=100000 # well under fzf's 1 MiB input buffer\nif [ \"$(wc -c < query.txt)\" -gt \"$max_query\" ]; then\n    echo \"query too large for tty input; use stdin instead\" >&2\n    exit 1\nfi\ncat items.txt | fzf --query=\"$(cat query.txt)\"\n\n# Go driver writing to fzf's tty: chunk with gaps so fzf's read loop flushes\nfunc writeChunked(w io.Writer, data []byte) error {\n    for len(data) > 0 {\n        n := len(data)\n        if n > 64*1024 {\n            n = 64 * 1024\n        }\n        if _, err := w.Write(data[:n]); err != nil {\n            return err\n        }\n        data = data[n:]\n        time.Sleep(5 * time.Millisecond) // idle gap lets fzf finish one buffer\n    }\n    return nil\n}","typeGuard":"func isInputBufferOverflow(stderr string) bool {\n    return strings.Contains(stderr, \"input buffer overflow\")\n}","tryCatchPattern":"// fzf exits fatally on this error; the only 'catch' is at the process level:\nout, err := cmd.CombinedOutput()\nif err != nil && strings.Contains(string(out), \"input buffer overflow\") {\n    // relaunch with the large payload delivered via stdin instead of the tty\n}","preventionTips":["Never paste data into fzf's query line; candidate data belongs on stdin.","Cap programmatic tty writes to fzf and chunk them with small pauses.","Keep terminal emulators' unlimited-paste of huge clipboards disabled or trimmed.","Investigate runaway tty writers (cat/echo loops, multiplexer floods) when fzf dies with this error."],"tags":["go","fzf","tui","terminal","input","memory"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}