{"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/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/chromium/browser_type.go#L540-L570","documentation":"When the browser module builds its extension-wide logger at launch, it reads the K6_BROWSER_LOG environment variable and calls logger.SetLevel with it. If the value is not one of panic, fatal, error, warn, warning, info, debug or trace, SetLevel rejects it and launch fails with this message. It is a pure configuration-validation error: nothing is wrong with the browser, only the env value.","triggerScenarios":"Setting K6_BROWSER_LOG to an unsupported value such as \"verbose\", \"all\", \"off\", \"LOG_DEBUG\", or a value with stray whitespace/quotes (common in CI YAML). The check runs as soon as the browser is first used in the script.","commonSituations":"Copying Playwright-style DEBUG env config into k6; leftover K6_BROWSER_LOG from other tooling in CI; confusing it with k6's own --loglevel flag, which accepts a different set of values.","solutions":["Set K6_BROWSER_LOG to one of the listed levels, e.g. K6_BROWSER_LOG=debug","Unset K6_BROWSER_LOG entirely if browser-specific debug logging is not needed","Use k6's own --loglevel flag for k6-wide log level instead of this browser-specific variable","Check the CI/compose environment for whitespace or quotes around the value"],"exampleFix":"# before\nK6_BROWSER_LOG=verbose k6 run script.js\n\n# after\nK6_BROWSER_LOG=debug k6 run script.js","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# Fail fast before k6 runs if K6_BROWSER_LOG is invalid\ncase \"$K6_BROWSER_LOG\" in\n  \"\"|panic|fatal|error|warn|warning|info|debug|trace) ;;\n  *) echo \"K6_BROWSER_LOG='$K6_BROWSER_LOG' invalid; use panic|fatal|error|warn|warning|info|debug|trace\"; exit 2;;\nesac\nk6 run script.js","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document the accepted level list next to wherever K6_BROWSER_LOG is set in CI","Prefer unsetting K6_BROWSER_LOG unless debugging the browser module","Use k6's --loglevel for k6-wide logging, not this variable"],"tags":["environment-variable","logging","configuration","browser"],"backgroundTag":"invalid-log-level","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}