grafana/k6 · error

invalid input, max length is %d

Error message

invalid input, max length is %d

What it means

StringField.Clean trims the user's console input and enforces the optional Max length; this error fires when the entered string is longer than the field allows (e.g. prompts for project/token IDs). It is a validation error in the interactive UI prompt loop, not a runtime crash.

Source

Thrown at internal/ui/form_fields.go:74

		if n != 1 {
			// Shouldn't happen, but just in case
			return string(result), errors.New("unexpected input when reading string field")
		} else if buf[0] == '\n' {
			return string(result), nil
		}
		result = append(result, buf[0])
	}
}

// Clean trims the spaces in the string and checks for min and max length
func (f StringField) Clean(s string) (string, error) {
	s = strings.TrimSpace(s)
	if f.Min != 0 && len(s) < f.Min {
		return "", fmt.Errorf("invalid input, min length is %d", f.Min)
	}
	if f.Max != 0 && len(s) > f.Max {
		return "", fmt.Errorf("invalid input, max length is %d", f.Max)
	}
	if s == "" {
		s = f.Default
	}
	return s, nil
}

// PasswordField masks password input
type PasswordField struct {
	Key   string
	Label string
	Min   int
}

// GetKey returns the field's key
func (f PasswordField) GetKey() string {
	return f.Key
}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Shorten the input below the maximum length shown in the error
  2. Re-run the command and provide a shorter value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/ui/form_fields.go:74 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/433bf381e7e3693c. Report an issue: GitHub.