tomnomnom/gron · error
error reading multiline input: %s: %s
Error message
error reading multiline input: %s: %s
What it means
gronStream reads one JSON object per line. If the underlying bufio.Scanner reports an I/O error while reading (sc.Err() != nil), the failure is wrapped as "error reading multiline input: %s: %s" with exit code exitFormStatements. The second %s carries the scanner error (e.g. token too long, read failure).
Source
Thrown at main.go:328
for _, s := range ss {
if opts&optJSON > 0 {
s, err = s.jsonify()
if err != nil {
goto out
}
}
fmt.Fprintln(w, conv(s))
}
}
if err = sc.Err(); err != nil {
errstr = "error reading multiline input: %s"
}
out:
if err != nil {
return exitFormStatements, fmt.Errorf(errstr+": %s", err)
}
return exitOK, nil
}
// ungron is the reverse of gron. Given assignment statements as input,
// it returns JSON. The only option is optMonochrome
func ungron(r io.Reader, w io.Writer, opts int) (int, error) {
scanner := bufio.NewScanner(r)
var maker statementmaker
// Allow larger internal buffer of the scanner (min: 64KiB ~ max: 1MiB)
scanner.Buffer(make([]byte, 64*1024), 1024*1024)
if opts&optJSON > 0 {
maker = statementFromJSONSpec
} else {
maker = statementFromStringMakerView on GitHub (pinned to 88a6234ea2)
Solutions
- Split or compact overly long lines so each is under the 1MiB scanner limit
- Check that the input source (file, pipe, socket) is healthy and not closing mid-read
- Retry the streaming read if the upstream producer was interrupted
- Fall back to plain `gron` (single document mode) if the data is one large JSON document rather than NDJSON
Example fix
// before $ gron -s < huge_line.json // bufio.Scanner: token too long // after $ jq -c . huge.json | split -l 1 --filter='gron' // or increase/max-lines under 1MiB per line
Defensive patterns
Strategy: fallback
Validate before calling
// pre-check line sizes before streaming
sc := bufio.NewScanner(r)
for sc.Scan() {
if len(sc.Bytes()) > 1024*1024 { /* split or reject line */ }
} Try / catch
code, err := gronStream(input, output, opts)
if err != nil {
if strings.HasPrefix(err.Error(), "error reading multiline input:") {
// retry stream or fall back to single-document gron
}
return err
} Prevention
- Keep NDJSON lines under 1MiB
- Ensure stream producers outlive the gron process
- Retry transient I/O failures on pipes/sockets
When it happens
Trigger: Reading `gron --stream` input from a broken pipe, a file that disappears mid-read, a failing pipe/fifo, or input lines exceeding the scanner's 1MiB buffer (bufio.ErrTooLong).
Common situations: Streaming from a tail -f or socket that errors mid-stream; huge single-line JSON documents over 1MB in a line-oriented stream; disk/network I/O faults while reading stdin.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- failed to read input statements
- non-assignment statement
- invalid JSON layout
- invalid statement
- statement has no value
AI-assisted analysis of tomnomnom/gron@88a6234ea2 (2026-09-06).
Data as JSON: /api/errors/6bb860cabb1f1ab2.
Report an issue: GitHub.