grafana/k6 · error

fromLine must be less than or equal to toLine

Error message

fromLine must be less than or equal to toLine

What it means

Raised in newParserOptionsFrom when both fromLine and toLine options are provided and fromLine is greater than or equal to toLine, which would define an empty or inverted line range for the CSV parser.

Solutions

  1. Set fromLine strictly less than toLine, e.g. {fromLine: 1, toLine: 10}
  2. Omit fromLine or toLine if you only need one bound
  3. Use 0-based non-negative line indices consistent with the reader's expectations
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/experimental/csv/module.go:363 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/6815e4de362fa9fe. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/experimental/csv/module.go:363

	if v := obj.Get("skipFirstLine"); v != nil {
		options.SkipFirstLine = v.ToBoolean()
	}

	if v := obj.Get("fromLine"); v != nil {
		options.FromLine = null.IntFrom(v.ToInteger())
	}

	if v := obj.Get("toLine"); v != nil {
		options.ToLine = null.IntFrom(v.ToInteger())
	}

	if v := obj.Get("asObjects"); v != nil {
		options.AsObjects = null.BoolFrom(v.ToBoolean())
	}

	if options.FromLine.Valid && options.ToLine.Valid && options.FromLine.Int64 >= options.ToLine.Int64 {
		return options, fmt.Errorf("fromLine must be less than or equal to toLine")
	}

	return options, nil
}

View on GitHub (pinned to 01ffac6f24)