{"record":{"id":"5b9227f78e935f76","repo":"grafana/k6","slug":"invalid-tag-empty-name","errorCode":null,"errorMessage":"invalid tag, empty name","messagePattern":"invalid tag, empty name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/options.go","lineNumber":18,"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()\")","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/cmd/options.go#L1-L36","documentation":"Raised while parsing the --tag flag (parseTagNameValue, internal/cmd/options.go:251): a tag argument must look like name=value, and this sentinel means the string starts with '=' — so splitting on the first '=' yields an empty name. The offending tag is wrapped as \"error parsing tag '<input>'\" in the reported message.","triggerScenarios":"Running k6 with `--tag \"=value\"` or `--tag \"=value=x\"`; usually the result of a missing name in a templated/quoted flag value (e.g. --tag \"${NAME}=v\" with NAME unset).","commonSituations":"CI scripts interpolating the tag name from an environment variable that is empty; a stray space or quote so the name lands outside the string; refactoring tag flags by hand.","solutions":["Give the tag a name: `--tag myname=value`","If the name comes from a variable, assert it is non-empty before building the command","List all --tag flags you pass and check each has text on both sides of the first '='"],"exampleFix":"# before\nk6 run --tag \"=$ENV=prod\" script.js   # name missing -> invalid tag, empty name\n\n# after\nk6 run --tag \"env=prod\" script.js","handlingStrategy":"validation","validationCode":"# reject tag args with an empty name side before running k6\nfor t in \"$@\"; do\n  case \"$t\" in\n    =*|\"\"|*=) echo \"malformed tag '$t' (expected 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":["Always write --tag name=value with non-empty text on both sides of the first '='","Expand templated names from checked env vars (:-default or a non-empty assertion)","When building k6 argv programmatically, filter out empty tag entries"],"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"}