{"record":{"id":"722054d5beda7a2d","repo":"grafana/k6","slug":"invalid-summary-mode","errorCode":null,"errorMessage":"invalid summary mode","messagePattern":"invalid summary mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lib/summary/summary.go","lineNumber":22,"sourceCode":"\t\"errors\"\n\t\"time\"\n\n\t\"go.k6.io/k6/v2/metrics\"\n)\n\n// A Mode specifies the mode of the Summary,\n// which defines how the end-of-test summary will be rendered.\ntype Mode int\n\n// Possible values for SummaryMode.\nconst (\n\tModeCompact  = Mode(iota) // Compact mode that only displays the total results.\n\tModeFull                  // Extended mode that displays total and partial results.\n\tModeDisabled              // Disabled. Can be used with --summary-mode=disabled.\n)\n\n// ErrInvalidSummaryMode indicates the serialized summary mode is invalid.\nvar ErrInvalidSummaryMode = errors.New(\"invalid summary mode\")\n\nconst (\n\tcompactString  = \"compact\"\n\tfullString     = \"full\"\n\tdisabledString = \"disabled\"\n)\n\n// MarshalJSON serializes a Mode as a human-readable string.\nfunc (m Mode) MarshalJSON() ([]byte, error) {\n\ttxt, err := m.MarshalText()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn []byte(`\"` + string(txt) + `\"`), nil\n}\n\n// MarshalText serializes a Mode as a human-readable string.\nfunc (m Mode) MarshalText() ([]byte, error) {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/lib/summary/summary.go#L4-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nk6 run --summary-mode=minimal script.js\n# after\nk6 run --summary-mode=compact script.js","handlingStrategy":"validation","validationCode":"// Go — validate before assigning\nimport \"go.k6.io/k6/v2/internal/lib/summary\"\n\nmode, err := summary.ValidateMode(userInput)\nif err != nil {\n    return fmt.Errorf(\"--summary-mode must be one of compact|full|disabled, got %q\", userInput)\n}\n\n// Shell\n[ \"$K6_SUMMARY_MODE\" = compact ] || [ \"$K6_SUMMARY_MODE\" = full ] || [ \"$K6_SUMMARY_MODE\" = disabled ] || unset K6_SUMMARY_MODE","typeGuard":"function isSummaryMode(v) {\n  return ['compact', 'full', 'disabled'].includes(v);\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["configuration","cli","serialization","summary","k6"],"backgroundTag":"invalid-config-value","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}