grafana/k6 · error
invalid summary mode
Error message
invalid summary mode
What it means
The summary mode type only accepts three values: 'compact', 'full', and 'disabled' (constants ModeCompact/ModeFull/ModeDisabled). Mode.MarshalText/UnmarshalText return ErrInvalidSummaryMode when asked to serialize a Mode outside 0-2 or deserialize a string that is not one of the three. It surfaces via the --summary-mode flag, the K6_SUMMARY_MODE environment variable, or JSON (de)serialization of summary options.
Solutions
- Use one of the exact values: compact, full, or disabled
- Check K6_SUMMARY_MODE and --summary-mode in your environment/CI for typos
- If parsing arbitrary input in Go, validate first with summary.ValidateMode(val) and show a friendly error listing the allowed values
- When deserializing configs, reject unknown summary modes before applying them
Example fix
# before k6 run --summary-mode=minimal script.js # after k6 run --summary-mode=compact script.js
Defensive patterns
Strategy: validation
Validate before calling
// Go — validate before assigning
import "go.k6.io/k6/v2/internal/lib/summary"
mode, err := summary.ValidateMode(userInput)
if err != nil {
return fmt.Errorf("--summary-mode must be one of compact|full|disabled, got %q", userInput)
}
// Shell
[ "$K6_SUMMARY_MODE" = compact ] || [ "$K6_SUMMARY_MODE" = full ] || [ "$K6_SUMMARY_MODE" = disabled ] || unset K6_SUMMARY_MODE Type guard
function isSummaryMode(v) {
return ['compact', 'full', 'disabled'].includes(v);
} Prevention
- Restrict UI/pipeline inputs to the three documented values before they reach k6
- Fail fast in CI with an explicit check on K6_SUMMARY_MODE rather than letting k6 exit mid-run
- Pin allowed values in shared scripts/templates so typos surface at review time
When it happens
Trigger: Running k6 with --summary-mode=verbose (typo or invented value); exporting K6_SUMMARY_MODE=fulll or K6_SUMMARY_MODE=minimal; deserializing an options JSON blob containing an unknown summary mode; constructing Mode(7) in Go and calling MarshalJSON/String on it.
Common situations: Typos in CI environment variables; scripts ported from older k6 versions or third-party tooling that emit non-standard mode names; dashboards that pass user input straight into the flag.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- invalid traces output
- no project specified. Use --project-id, set…
- access token not configured
- both K6_CLOUD_METRICS_PUSH_URL and K6_CLOUD_TEST_RUN_TOKEN…
- could not open
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/722054d5beda7a2d.
Report an issue: GitHub.
Appendix: source
Thrown at internal/lib/summary/summary.go:22
"errors"
"time"
"go.k6.io/k6/v2/metrics"
)
// A Mode specifies the mode of the Summary,
// which defines how the end-of-test summary will be rendered.
type Mode int
// Possible values for SummaryMode.
const (
ModeCompact = Mode(iota) // Compact mode that only displays the total results.
ModeFull // Extended mode that displays total and partial results.
ModeDisabled // Disabled. Can be used with --summary-mode=disabled.
)
// ErrInvalidSummaryMode indicates the serialized summary mode is invalid.
var ErrInvalidSummaryMode = errors.New("invalid summary mode")
const (
compactString = "compact"
fullString = "full"
disabledString = "disabled"
)
// MarshalJSON serializes a Mode as a human-readable string.
func (m Mode) MarshalJSON() ([]byte, error) {
txt, err := m.MarshalText()
if err != nil {
return nil, err
}
return []byte(`"` + string(txt) + `"`), nil
}
// MarshalText serializes a Mode as a human-readable string.
func (m Mode) MarshalText() ([]byte, error) {View on GitHub (pinned to 01ffac6f24)