grafana/k6 · error

%s should be a boolean

Error message

%s should be a boolean

What it means

parseBoolOpt runs strconv.ParseBool on every boolean-valued browser environment variable (K6_BROWSER_HEADLESS, K6_BROWSER_ENABLE_DEBUGGING) during BrowserOptions.Parse. ParseBool only accepts 1/t/T/TRUE/true/True/0/f/F/FALSE/false/False; anything else (e.g. "yes", "enabled", an empty value) fails and the error names the offending variable.

Source

Thrown at internal/js/modules/k6/browser/common/browser_options.go:137

	if !bo.isRemoteBrowser {
		return false
	}

	shouldIgnoreIfBrowserIsRemote := map[string]struct{}{
		env.BrowserArguments:         {},
		env.BrowserExecutablePath:    {},
		env.BrowserHeadless:          {},
		env.BrowserIgnoreDefaultArgs: {},
	}
	_, ignore := shouldIgnoreIfBrowserIsRemote[opt]

	return ignore
}

func parseBoolOpt(k, v string) (bool, error) {
	b, err := strconv.ParseBool(v)
	if err != nil {
		return false, fmt.Errorf("%s should be a boolean", k)
	}

	return b, nil
}

func parseTimeOpt(k, v string) (time.Duration, error) {
	t, err := types.GetDurationValue(v)
	if err != nil {
		return time.Duration(0), fmt.Errorf("%s should be a time duration value: %w", k, err)
	}

	return t, nil
}

func parseListOpt(v string) []string {
	elems := strings.Split(v, ",")
	// If last element is a void string,
	// because value contained an ending comma,

View on GitHub (pinned to 93accf6570)

Solutions

  1. Use a value strconv.ParseBool understands: true/false, 1/0, T/F.
  2. Unset the variable instead of leaving it empty if you want the default behavior.
  3. Check for stray quotes or trailing whitespace in the exported value.

Example fix

# before
export K6_BROWSER_HEADLESS=yes

# after
export K6_BROWSER_HEADLESS=true
Defensive patterns

Strategy: validation

Validate before calling

# pre-flight in CI before k6 runs
for v in "${K6_BROWSER_HEADLESS:-}" "${K6_BROWSER_ENABLE_DEBUGGING:-}"; do
  if [ -n "$v" ] && ! echo "$v" | grep -qxE '(1|0|t|f|T|F|true|false|TRUE|FALSE|True|False)'; then
    echo "boolean env var has invalid value: '$v'" >&2; exit 1;
  fi
done

Prevention

When it happens

Trigger: Exporting K6_BROWSER_HEADLESS=yes, K6_BROWSER_HEADLESS=enabled, K6_BROWSER_ENABLE_DEBUGGING=1-with-junk, or an empty/whitespace value before running k6 with the browser module.

Common situations: CI pipelines that set booleans as yes/no; .env files with K6_BROWSER_HEADLESS="" (quotes leak into the value); shell scripts using $VAR uninitialized, producing an empty string.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/103988a5120f87f2. Report an issue: GitHub.