grafana/k6 · error
invalid tag, empty name
Error message
invalid tag, empty name
What it means
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.
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 '='
Example fix
# before k6 run --tag "=$ENV=prod" script.js # name missing -> invalid tag, empty name # after k6 run --tag "env=prod" script.js
Defensive patterns
Strategy: validation
Validate before calling
# reject tag args with an empty name side before running k6
for t in "$@"; do
case "$t" in
=*|""|*=) echo "malformed tag '$t' (expected name=value)"; exit 1 ;;
esac
done Type guard
function isValidTag(s) {
const i = s.indexOf('=');
return i > 0 && i < s.length - 1;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- invalid tag, empty string
- invalid tag, empty value
- a function is expected as the second argument of…
- cannot be null or undefined
- empty name provided to SharedArray's constructor
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/5b9227f78e935f76.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/options.go:18
package cmd
import (
"errors"
"fmt"
"strings"
"github.com/spf13/pflag"
"gopkg.in/guregu/null.v3"
"go.k6.io/k6/v2/internal/build"
"go.k6.io/k6/v2/lib"
"go.k6.io/k6/v2/lib/types"
"go.k6.io/k6/v2/metrics"
)
var (
errTagEmptyName = errors.New("invalid tag, empty name")
errTagEmptyValue = errors.New("invalid tag, empty value")
errTagEmptyString = errors.New("invalid tag, empty string")
)
func optionFlagSet() *pflag.FlagSet {
flags := pflag.NewFlagSet("", 0)
flags.SortFlags = false
flags.Bool("once", false, "run the test with 1 VU and 1 iteration")
flags.StringSlice("scenario", nil, "run scenarios by name (comma-separated)")
flags.Int64P("vus", "u", 1, "number of virtual users")
flags.DurationP("duration", "d", 0, "test duration limit")
flags.Int64P("iterations", "i", 0, "script total iteration limit (among all VUs)")
flags.StringSliceP("stage", "s", nil, "add a `stage`, as `[duration]:[target]`")
flags.String("execution-segment", "", "limit execution to the specified segment, e.g. 10%, 1/3, 0.2:2/3")
flags.String("execution-segment-sequence", "", "the execution segment sequence") // TODO better description
flags.BoolP("paused", "p", false, "start the test in a paused state")
flags.Bool("no-setup", false, "don't run setup()")View on GitHub (pinned to 8d06114777)