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
- Use a value strconv.ParseBool understands: true/false, 1/0, T/F.
- Unset the variable instead of leaving it empty if you want the default behavior.
- 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
- Use only true/false or 1/0 for K6_BROWSER_* booleans.
- Unset variables you do not need rather than leaving them empty.
- Quote .env values correctly; avoid yes/no spellings.
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
- env var '%s' is not a valid boolean value: %w
- both K6_CLOUD_METRICS_PUSH_URL and K6_CLOUD_TEST_RUN_TOKEN m
- K6_CLOUD_LOGS_PUSH_URL requires K6_CLOUD_TEST_RUN_TOKEN
- WebSocket endpoint cannot be empty
- k6 couldn't detect google chrome or a chromium-supported bro
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/103988a5120f87f2.
Report an issue: GitHub.