grafana/k6 · error

array value for key `%s` didn't end

Error message

array value for key `%s` didn't end

What it means

An array value opened with '[' was never closed before the input ended; the tokenizer scanned to end-of-string without finding ']'. A typical cause is a truncated otel/traces option string like 'otel=k=[v1,v2'. The error names the key whose array was left unterminated, and the whole parse fails.

Source

Thrown at internal/lib/strvals/parser.go:65

	return t.s[start:]
}

func (t *tokenizer) readArray() (string, error) {
	start := t.i
	for ; t.i < len(t.s); t.i++ {
		if t.s[t.i] == ']' {
			if t.i+1 == len(t.s) || t.s[t.i+1] == ',' {
				t.i += 2

				return t.s[start : t.i-2], nil
			}
			t.i++

			return t.s[start : t.i-1], fmt.Errorf("there was no ',' after an array with key '%s'", t.currentKey)
		}
	}

	return t.s[start:], fmt.Errorf("array value for key `%s` didn't end", t.currentKey)
}

// Parse parses the input string into key-value tokens following strvals format:
// name=value,topname.subname=value.
func Parse(s string) ([]Token, error) {
	result := []Token{}
	t := &tokenizer{s: s}

	var err error
	var value string
	for t.i < len(s) {
		t.currentKey, err = t.readKey()
		if err != nil {
			return result, err
		}
		if t.s[t.i] == '[' {
			t.i++
			value, err = t.readArray()

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Close the array with a matching ']'
  2. Check for truncated or partially-edited option strings
  3. Escape literal brackets in values per the strvals format if they are not meant as arrays
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/lib/strvals/parser.go:65 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/321742d01b2ae308. Report an issue: GitHub.