tomnomnom/gron · error

no statements were parsed

Error message

no statements were parsed

What it means

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.

Source

Thrown at statements.go:295

	// Get all the individually parsed statements
	var parsed []interface{}
	for _, s := range ss {
		u, err := ungronTokens(s)

		switch err.(type) {
		case nil:
			// no problem :)
		case errRecoverable:
			continue
		default:
			return nil, errors.Wrapf(err, "ungron failed for `%s`", s)
		}

		parsed = append(parsed, u)
	}

	if len(parsed) == 0 {
		return nil, fmt.Errorf("no statements were parsed")
	}

	merged := parsed[0]
	for _, p := range parsed[1:] {
		m, err := recursiveMerge(merged, p)
		if err != nil {
			return nil, errors.Wrap(err, "failed to merge statements")
		}
		merged = m
	}
	return merged, nil

}

// Less compares two statements for sort.Sort
// Implements a natural sort to keep array indexes in order
func (ss statements) Less(a, b int) bool {

View on GitHub (pinned to 88a6234ea2)

Solutions

  1. Check the input is non-empty and contains at least one valid `json... = value;` line before running ungron
  2. Fix upstream commands so they emit statements before piping to ungron
  3. In --json mode, verify each line is a valid JSON spec array

Example fix

// before
$ gron --ungron < /dev/null   // no statements were parsed

// after
$ test -s out.gron && gron --ungron < out.gron
Defensive patterns

Strategy: validation

Validate before calling

if fi, err := os.Stdin.Stat(); err == nil && fi.Size() == 0 && fi.Mode()&os.ModeCharDevice != 0 {
	// stdin empty/terminal: don't call ungron
}

Try / catch

code, err := ungron(input, output, opts)
if err != nil {
	if err.Error() == "no statements were parsed" {
		// check upstream produced at least one statement
	}
	return err
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of tomnomnom/gron@88a6234ea2 (2026-09-06). Data as JSON: /api/errors/ce35e3c595fa5a49. Report an issue: GitHub.