{"record":{"id":"c7a9e452839f09e3","repo":"grafana/k6","slug":"env-var-s-is-not-a-valid-boolean-value-w","errorCode":null,"errorMessage":"env var '%s' is not a valid boolean value: %w","messagePattern":"env var '(.+?)' is not a valid boolean value: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/runtime_options.go","lineNumber":159,"sourceCode":"\t\topts.TracesOutput = null.StringFrom(envVar)\n\t}\n\n\t// If enabled, gather the actual system environment variables\n\tif opts.IncludeSystemEnvVars.Bool {\n\t\topts.Env = environment\n\t}\n\n\treturn opts, nil\n}\n\nfunc saveBoolFromEnv(env map[string]string, varName string, placeholder *null.Bool) error {\n\tstrValue, ok := env[varName]\n\tif !ok {\n\t\treturn nil\n\t}\n\tval, err := strconv.ParseBool(strValue)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"env var '%s' is not a valid boolean value: %w\", varName, err)\n\t}\n\t// Only override if not explicitly set via the CLI flag\n\tif !placeholder.Valid {\n\t\t*placeholder = null.BoolFrom(val)\n\t}\n\treturn nil\n}\n","sourceCodeStart":141,"sourceCodeEnd":167,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/runtime_options.go#L141-L167","documentation":"Boolean-typed K6_* environment variables (K6_INCLUDE_SYSTEM_ENV_VARS, K6_NO_THRESHOLDS, K6_NEW_MACHINE_READABLE_SUMMARY) are read by saveBoolFromEnv and parsed with strconv.ParseBool, which accepts only 1/t/T/TRUE/true/True/0/f/F/FALSE/false/False. Any other word (yes, on, enable) yields \"env var 'K6_...' is not a valid boolean value\". A valid value is applied only when the corresponding CLI flag was not set explicitly.","triggerScenarios":"Exporting K6_NO_THRESHOLDS=yes, K6_INCLUDE_SYSTEM_ENV_VARS=on, or K6_NEW_MACHINE_READABLE_SUMMARY=enable before running k6; CI variables defined at organization level with inconsistent boolean spellings.","commonSituations":"Porting settings from tools where 'yes'/'on' are valid booleans; CI dashboards pre-filling K6_* variables with arbitrary text; shell scripts building K6_* values from unchecked user input.","solutions":["Set the variable to a ParseBool-accepted literal — 'true' or 'false' is the safe choice","Unset the variable if you did not intend to override the default","Audit the environment for stray K6_* variables: env | grep '^K6_'"],"exampleFix":"# before\nexport K6_INCLUDE_SYSTEM_ENV_VARS=yes\n# after\nexport K6_INCLUDE_SYSTEM_ENV_VARS=true","handlingStrategy":"validation","validationCode":"# Accept only strconv.ParseBool literals for K6_* booleans before launching k6\nfor v in \"${K6_INCLUDE_SYSTEM_ENV_VARS-}\" \"${K6_NO_THRESHOLDS-}\" \"${K6_NEW_MACHINE_READABLE_SUMMARY-}\"; do\n  [ -z \"$v\" ] && continue\n  case \"$v\" in 1|t|T|true|TRUE|True|0|f|F|false|FALSE|False) ;; *) echo \"bad boolean: $v\" >&2; exit 2;; esac\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only true/false for K6_* boolean variables","Audit exported variables once with env | grep '^K6_'","Remember CLI flags override env values only when explicitly set — unset env overrides when pinning flags"],"tags":["environment","configuration","boolean","cli"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}