{"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.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()\")\n\tflags.Int64(\"max-redirects\", 10, \"follow at most n redirects\")\n\tflags.Int64(\"batch\", 20, \"max parallel batch reqs\")","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/options.go#L1-L37","documentation":"parseTagNameValue rejects --tag values with no '=' at all (idx == -1) or with '=' as the last character (idx == len-1): both mean the value side is empty. Every CLI tag must be a complete name=value pair; a bare name or a dangling 'name=' cannot form a metric tag.","triggerScenarios":"Running with --tag \"env\" (no '='), --tag \"env=\" (trailing '='), or the equivalent entries in K6_TAGS / repeated --tag flags where the value portion after the first '=' is empty.","commonSituations":"Forgetting the =value half when scripting --tag flags; a $TAG_VALUE variable that is empty so the shell produces \"env=\"; assuming --tag works like a boolean flag; copying a tag list where the value was dropped.","solutions":["Write the full pair: --tag \"env=prod\"","If tag values come from variables, default or validate them so the '=' always has a right-hand side","Note that an intentionally empty value is not representable via this flag — choose a placeholder like 'unknown' if you need one"],"exampleFix":"# before\nk6 run --tag \"env\" script.js        # ERR: invalid tag, empty value\nk6 run --tag \"env=\" script.js       # ERR: invalid tag, empty value\n\n# after\nk6 run --tag \"env=prod\" script.js","handlingStrategy":"validation","validationCode":"# every tag must be a full name=value pair\nfor t in \"${TAGS[@]}\"; do\n  case \"$t\" in\n    *=?*) ;;      # name=value with non-empty value: OK\n    *) echo \"invalid tag '$t': expected name=value\" >&2; exit 1 ;;\n  esac\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default empty tag values in scripts: : \"${TAG_VALUE:=unknown}\"","Reject tags without '=' or ending in '=' in a shared pre-run lint","Remember the CLI cannot express an intentionally empty tag value — use a placeholder"],"tags":["cli","tags","flags","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}