{"record":{"id":"33ca071f6c949161","repo":"tomnomnom/gron","slug":"failed-to-read-input-statements","errorCode":null,"errorMessage":"failed to read input statements","messagePattern":"failed to read input statements","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":359,"sourceCode":"\tscanner.Buffer(make([]byte, 64*1024), 1024*1024)\n\n\tif opts&optJSON > 0 {\n\t\tmaker = statementFromJSONSpec\n\t} else {\n\t\tmaker = statementFromStringMaker\n\t}\n\n\t// Make a list of statements from the input\n\tvar ss statements\n\tfor scanner.Scan() {\n\t\ts, err := maker(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn exitParseStatements, err\n\t\t}\n\t\tss.add(s)\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn exitReadInput, fmt.Errorf(\"failed to read input statements\")\n\t}\n\n\t// turn the statements into a single merged interface{} type\n\tmerged, err := ss.toInterface()\n\tif err != nil {\n\t\treturn exitParseStatements, err\n\t}\n\n\t// If there's only one top level key and it's \"json\", make that the top level thing\n\tmergedMap, ok := merged.(map[string]interface{})\n\tif ok {\n\t\tif len(mergedMap) == 1 {\n\t\t\tif _, exists := mergedMap[\"json\"]; exists {\n\t\t\t\tmerged = mergedMap[\"json\"]\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/tomnomnom/gron/blob/88a6234ea2d0c487090988182ad9a7cdf6def924/main.go#L341-L377","documentation":"The ungron action reads input statements line by line. If bufio.Scanner returns a read error (scanner.Err() != nil) — as opposed to clean EOF — ungron returns the fixed message \"failed to read input statements\" with exit code exitReadInput. Notably the underlying cause is not wrapped, so the original error is lost.","triggerScenarios":"I/O failure while `gron --ungron` reads stdin or a file: broken pipe, medium removed, permission/IO fault, or input lines exceeding the 1MiB scanner buffer limit.","commonSituations":"Ungron-ing from a FIFO or process substitution whose writer died; ungron-ing a file with extremely long lines (>1MB) that trips bufio.ErrTooLong; reading from a flaky network mount.","solutions":["Keep statement lines under the 1MiB scanner limit (split large values)","Re-run once the input source is stable/available","Feed ungron from a regular file or pipe with a live writer","Capture the underlying scanner error by reproducing the read in a test, since this message hides the cause"],"exampleFix":"// before\n$ gron --ungron < (producer.sh)   // producer died mid-stream\n\n// after\n$ producer.sh > out.gron && gron --ungron < out.gron","handlingStrategy":"fallback","validationCode":"fi, err := os.Stat(path)\nif err != nil || !fi.Mode().IsRegular() { /* avoid unstable sources */ }","typeGuard":null,"tryCatchPattern":"code, err := ungron(input, output, opts)\nif err != nil {\n\tif err.Error() == \"failed to read input statements\" {\n\t\t// retry with a stable file source; note cause is hidden\n\t}\n\treturn err\n}","preventionTips":["Ungron from regular files or live pipes, not dying process substitutions","Keep statement lines under the 1MiB scanner buffer","Persist intermediate output to disk before ungron-ing"],"tags":["go","gron","io","stdin"],"backgroundTag":"file-read-failed","analyzedSha":"88a6234ea2d0c487090988182ad9a7cdf6def924","analyzedAt":"2026-09-06T11:35:31.658Z","contentChangedAt":"2026-09-06T11:35:31.658Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}