{"record":{"id":"ce35e3c595fa5a49","repo":"tomnomnom/gron","slug":"no-statements-were-parsed","errorCode":null,"errorMessage":"no statements were parsed","messagePattern":"no statements were parsed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"statements.go","lineNumber":295,"sourceCode":"\t// Get all the individually parsed statements\n\tvar parsed []interface{}\n\tfor _, s := range ss {\n\t\tu, err := ungronTokens(s)\n\n\t\tswitch err.(type) {\n\t\tcase nil:\n\t\t\t// no problem :)\n\t\tcase errRecoverable:\n\t\t\tcontinue\n\t\tdefault:\n\t\t\treturn nil, errors.Wrapf(err, \"ungron failed for `%s`\", s)\n\t\t}\n\n\t\tparsed = append(parsed, u)\n\t}\n\n\tif len(parsed) == 0 {\n\t\treturn nil, fmt.Errorf(\"no statements were parsed\")\n\t}\n\n\tmerged := parsed[0]\n\tfor _, p := range parsed[1:] {\n\t\tm, err := recursiveMerge(merged, p)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to merge statements\")\n\t\t}\n\t\tmerged = m\n\t}\n\treturn merged, nil\n\n}\n\n// Less compares two statements for sort.Sort\n// Implements a natural sort to keep array indexes in order\nfunc (ss statements) Less(a, b int) bool {\n","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/tomnomnom/gron/blob/88a6234ea2d0c487090988182ad9a7cdf6def924/statements.go#L277-L313","documentation":"statements.toInterface() merges all parsed statements into one interface{}. If no statement successfully parsed (len(parsed) == 0), there is nothing to merge and it returns \"no statements were parsed\". ungron surfaces this with exit code exitParseStatements.","triggerScenarios":"`gron --ungron` receiving only input that no statement maker could parse: entirely empty input, only blank lines, or `--json` mode where every line failed statementFromJSONSpec.","commonSituations":"Running `gron --ungron` with empty stdin (e.g. a command producing no output before the pipe); a file containing only comments/whitespace; piping the output of a gron run that itself failed.","solutions":["Check the input is non-empty and contains at least one valid `json... = value;` line before running ungron","Fix upstream commands so they emit statements before piping to ungron","In --json mode, verify each line is a valid JSON spec array"],"exampleFix":"// before\n$ gron --ungron < /dev/null   // no statements were parsed\n\n// after\n$ test -s out.gron && gron --ungron < out.gron","handlingStrategy":"validation","validationCode":"if fi, err := os.Stdin.Stat(); err == nil && fi.Size() == 0 && fi.Mode()&os.ModeCharDevice != 0 {\n\t// stdin empty/terminal: don't call ungron\n}","typeGuard":null,"tryCatchPattern":"code, err := ungron(input, output, opts)\nif err != nil {\n\tif err.Error() == \"no statements were parsed\" {\n\t\t// check upstream produced at least one statement\n\t}\n\treturn err\n}","preventionTips":["Check the input is non-empty before ungron","Verify the upstream gron run exited 0","Never pipe a failed/empty producer into ungron"],"tags":["go","gron","empty-input","validation"],"backgroundTag":"empty-result-set","analyzedSha":"88a6234ea2d0c487090988182ad9a7cdf6def924","analyzedAt":"2026-09-06T11:35:31.658Z","contentChangedAt":"2026-09-06T11:35:31.658Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}