grafana/k6 · error
invalid tag, empty value
Error message
invalid tag, empty value
What it means
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>'".
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
Example fix
# before k6 run --tag env --tag build= script.js # missing/empty value # after k6 run --tag env=staging --tag build=42 script.js
Defensive patterns
Strategy: validation
Validate before calling
# every --tag argument must contain '=' with a non-empty value side
for t in "$@"; do
case "$t" in
*=) echo "tag '$t' is missing its value"; exit 1 ;;
*|=*) : ;;
*) echo "tag '$t' must be name=value"; exit 1 ;;
esac
done Type guard
function isValidTag(s) {
const i = s.indexOf('=');
return i > 0 && i < s.length - 1;
} Prevention
- 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 '='
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid tag, empty name
- invalid tag, empty string
- 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/9200ff44d5ace24a.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/options.go:19
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()")
flags.Bool("no-teardown", false, "don't run teardown()")View on GitHub (pinned to 8d06114777)