{"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/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/runtime_options.go#L141-L167","documentation":"Boolean runtime options can be set from the environment; saveBoolFromEnv parses K6_INCLUDE_SYSTEM_ENV_VARS and K6_NO_THRESHOLDS with strconv.ParseBool. Only 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False are accepted — anything else ('yes', 'on', 'enable') aborts startup with this error naming the offending variable. An explicitly set CLI flag is not overridden by the env value.","triggerScenarios":"K6_NO_THRESHOLDS=yes k6 run script.js; K6_INCLUDE_SYSTEM_ENV_VARS=on; docker-compose env files or CI variables using yes/no conventions.","commonSituations":"Porting configuration from tools that accept yes/no or on/off; hand-edited .env files; variable reused across tools with different boolean syntaxes.","solutions":["Use an accepted boolean literal: K6_NO_THRESHOLDS=true (or 1/0)","Unset the variable if you don't need the option","Fix the definition in the env file / CI settings that injected the bad value"],"exampleFix":"# before\nK6_NO_THRESHOLDS=yes k6 run script.js\n\n# after\nK6_NO_THRESHOLDS=true k6 run script.js","handlingStrategy":"validation","validationCode":"# preflight boolean env vars accepted by Go's ParseBool\ncheck_bool_env() {\n  v=\"${!1:-}\"\n  [ -z \"$v\" ] && return 0\n  case \"${v,,}\" in\n    1|t|true|0|f|false) return 0;;\n    *) echo \"$1=$v is not a valid boolean (use true/false/1/0)\" >&2; return 1;;\n  esac\n}\ncheck_bool_env K6_NO_THRESHOLDS && check_bool_env K6_INCLUDE_SYSTEM_ENV_VARS || exit 1\nk6 run script.js","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only true/false/1/0 for K6 boolean env vars — 'yes' and 'on' are rejected","Standardize one boolean convention across the CI env files for all tools","Only K6_INCLUDE_SYSTEM_ENV_VARS and K6_NO_THRESHOLDS flow through this check — keep their definitions in reviewed config"],"tags":["k6","environment-variables","boolean","validation","config"],"backgroundTag":"invalid-env-var-value","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}