{"record":{"id":"9200ff44d5ace24a","repo":"grafana/k6","slug":"invalid-tag-empty-value","errorCode":null,"errorMessage":"invalid tag, empty value","messagePattern":"invalid tag, empty value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/options.go","lineNumber":19,"sourceCode":"package cmd\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/spf13/pflag\"\n\t\"gopkg.in/guregu/null.v3\"\n\n\t\"go.k6.io/k6/v2/internal/build\"\n\t\"go.k6.io/k6/v2/lib\"\n\t\"go.k6.io/k6/v2/lib/types\"\n\t\"go.k6.io/k6/v2/metrics\"\n)\n\nvar (\n\terrTagEmptyName   = errors.New(\"invalid tag, empty name\")\n\terrTagEmptyValue  = errors.New(\"invalid tag, empty value\")\n\terrTagEmptyString = errors.New(\"invalid tag, empty string\")\n)\n\nfunc optionFlagSet() *pflag.FlagSet {\n\tflags := pflag.NewFlagSet(\"\", 0)\n\tflags.SortFlags = false\n\n\tflags.Bool(\"once\", false, \"run the test with 1 VU and 1 iteration\")\n\tflags.StringSlice(\"scenario\", nil, \"run scenarios by name (comma-separated)\")\n\tflags.Int64P(\"vus\", \"u\", 1, \"number of virtual users\")\n\tflags.DurationP(\"duration\", \"d\", 0, \"test duration limit\")\n\tflags.Int64P(\"iterations\", \"i\", 0, \"script total iteration limit (among all VUs)\")\n\tflags.StringSliceP(\"stage\", \"s\", nil, \"add a `stage`, as `[duration]:[target]`\")\n\tflags.String(\"execution-segment\", \"\", \"limit execution to the specified segment, e.g. 10%, 1/3, 0.2:2/3\")\n\tflags.String(\"execution-segment-sequence\", \"\", \"the execution segment sequence\") // TODO better description\n\tflags.BoolP(\"paused\", \"p\", false, \"start the test in a paused state\")\n\tflags.Bool(\"no-setup\", false, \"don't run setup()\")\n\tflags.Bool(\"no-teardown\", false, \"don't run teardown()\")","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/cmd/options.go#L1-L37","documentation":"Raised while parsing the --tag flag in parseTagNameValue: the argument contains no '=' at all, or ends with '=' so the value side is empty. CLI run-tags must be complete name=value pairs; unlike script-level tags, an empty value is not accepted from the command line. The wrapper message is \"error parsing tag '<input>'\".","triggerScenarios":"Running `k6 run --tag check_id script.js` (forgot '=value'), or `--tag env=` (trailing '=' with nothing after it); commonly `--tag \"$TAG\"` where TAG holds a bare key.","commonSituations":"Assuming --tag works like a label switch (name only); copy-pasting tag names without values from docs or tickets; shell variables containing just the key half.","solutions":["Write the full pair: `--tag name=value` (empty values are not allowed via CLI — pick a placeholder if needed)","Audit shell/CI variables feeding --tag to ensure they contain an '=' with non-empty text after it","Consider defining tags in the script's options.tags instead if you need emptier/dynamic handling"],"exampleFix":"# before\nk6 run --tag env --tag build= script.js   # missing/empty value\n\n# after\nk6 run --tag env=staging --tag build=42 script.js","handlingStrategy":"validation","validationCode":"# every --tag argument must contain '=' with a non-empty value side\nfor t in \"$@\"; do\n  case \"$t\" in\n    *=) echo \"tag '$t' is missing its value\"; exit 1 ;;\n    *|=*) : ;;\n    *) echo \"tag '$t' must be name=value\"; exit 1 ;;\n  esac\ndone","typeGuard":"function isValidTag(s) {\n  const i = s.indexOf('=');\n  return i > 0 && i < s.length - 1;\n}","tryCatchPattern":null,"preventionTips":["k6 CLI tags always need an explicit value — unlike some tools' bare-label flags","When the value is genuinely empty, choose a placeholder like name=none instead","Lint CI command arrays for tag entries lacking '=' or ending in '='"],"tags":["k6","cli-flags","tag","validation"],"backgroundTag":"malformed-flag-value","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}