{"record":{"id":"33c57505e61af6a1","repo":"grafana/k6","slug":"invalid-log-level-q-should-be-one-of-panic-fat","errorCode":null,"errorMessage":"invalid log level %q, should be one of: panic, fatal, error, warn, warning, info, debug, trace","messagePattern":"invalid log level %q, should be one of: panic, fatal, error, warn, warning, info, debug, trace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/chromium/browser_type.go","lineNumber":558,"sourceCode":"\t\thostResolver = append(hostResolver, fmt.Sprintf(\"MAP %s %s\", k, v))\n\t}\n\tif len(hostResolver) > 0 {\n\t\tsort.Strings(hostResolver)\n\t\tflags[\"host-resolver-rules\"] = strings.Join(hostResolver, \",\")\n\t}\n\n\treturn nil\n}\n\n// makeLogger makes and returns an extension wide logger.\nfunc makeLogger(ctx context.Context, envLookup env.LookupFunc) (*log.Logger, error) {\n\tvar (\n\t\tk6Logger = k6ext.GetVU(ctx).State().Logger\n\t\tlogger   = log.New(k6Logger, common.GetIterationID(ctx))\n\t)\n\tif el, ok := envLookup(env.LogLevel); ok {\n\t\tif logger.SetLevel(el) != nil {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"invalid log level %q, should be one of: panic, fatal, error, warn, warning, info, debug, trace\",\n\t\t\t\tel,\n\t\t\t)\n\t\t}\n\t}\n\tif _, ok := envLookup(env.LogCaller); ok {\n\t\tlogger.ReportCaller()\n\t}\n\n\treturn logger, nil\n}\n","sourceCodeStart":540,"sourceCodeEnd":570,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/chromium/browser_type.go#L540-L570","documentation":"Returned by makeLogger during init (both Launch and Connect paths) when the K6_BROWSER_LOG_LEVEL environment variable is set but log.Logger.SetLevel rejects its value. Acceptable values are exactly: panic, fatal, error, warn, warning, info, debug, trace. The error aborts browser initialization before anything else happens, so it masks all later work until fixed.","triggerScenarios":"Exporting K6_BROWSER_LOG_LEVEL with an unsupported value such as 'verbose', 'DEBUG' (case sensitivity depends on the level parser — safest to use lowercase), 'all', or an empty string; CI pipelines inheriting a LOG_LEVEL-style var renamed incorrectly.","commonSituations":"Teams standardizing on a 'debug'/'trace' convention but writing 'DEBUG' or 'fine'; copy-paste from k6's own K6_LOG_LEVEL which supports different values (info/debug) than the browser module; a stray space in the export: K6_BROWSER_LOG_LEVEL=' debug'.","solutions":["Set K6_BROWSER_LOG_LEVEL to one of the listed values, e.g. export K6_BROWSER_LOG_LEVEL=debug","Trim whitespace/case-fix the current value and retry","Unset the variable to fall back to k6's default logger level","Note the separate vars: K6_BROWSER_LOG_LEVEL (browser module) vs K6_LOG_LEVEL (k6 core) accept different sets"],"exampleFix":"# before\nexport K6_BROWSER_LOG_LEVEL=verbose\n\n# after\nexport K6_BROWSER_LOG_LEVEL=debug","handlingStrategy":"validation","validationCode":"const VALID = ['panic','fatal','error','warn','warning','info','debug','trace'];\nif (__ENV.K6_BROWSER_LOG_LEVEL && !VALID.includes(__ENV.K6_BROWSER_LOG_LEVEL)) {\n  throw new Error(`K6_BROWSER_LOG_LEVEL='${__ENV.K6_BROWSER_LOG_LEVEL}' invalid; use one of: ${VALID.join(', ')}`);\n}","typeGuard":"function isBrowserLogLevel(v) {\n  return ['panic','fatal','error','warn','warning','info','debug','trace'].includes(String(v).toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["Use lowercase canonical levels for K6_BROWSER_LOG_LEVEL","Do not reuse K6_LOG_LEVEL values verbatim for the browser module","Add a startup check that fails the CI job on unknown browser env vars"],"tags":["configuration","environment-variables","logging","launch","connect"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}