{"record":{"id":"5ea95be129dc33f2","repo":"grafana/k6","slug":"browser-type-option-must-be-set","errorCode":null,"errorMessage":"browser type option must be set","messagePattern":"browser type option must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/browser_options.go","lineNumber":67,"sourceCode":"\treturn &BrowserOptions{\n\t\tHeadless:          true,\n\t\tLogCategoryFilter: \".*\",\n\t\tTimeout:           DefaultTimeout,\n\t\tisRemoteBrowser:   true,\n\t}\n}\n\n// Parse parses browser options from a JS object.\nfunc (bo *BrowserOptions) Parse(\n\tctx context.Context, logger *log.Logger, opts map[string]any, envLookup env.LookupFunc,\n) error {\n\t// Parse opts\n\tbt, ok := opts[optType]\n\t// Only 'chromium' is supported by now, so return error\n\t// if type option is not set, or if it's set and its value\n\t// is different than 'chromium'\n\tif !ok {\n\t\treturn errors.New(\"browser type option must be set\")\n\t}\n\tif bt != \"chromium\" {\n\t\treturn fmt.Errorf(\"unsupported browser type: %s\", bt)\n\t}\n\n\t// Parse env\n\tenvOpts := [...]string{\n\t\tenv.BrowserArguments,\n\t\tenv.BrowserEnableDebugging,\n\t\tenv.BrowserExecutablePath,\n\t\tenv.BrowserHeadless,\n\t\tenv.BrowserIgnoreDefaultArgs,\n\t\tenv.LogCategoryFilter,\n\t\tenv.BrowserGlobalTimeout,\n\t}\n\n\tfor _, e := range envOpts {\n\t\tev, ok := envLookup(e)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/browser_options.go#L49-L85","documentation":"BrowserOptions.Parse reads the type field from the browser options object and requires it: only 'chromium' is supported, so a missing type key returns this error (a present-but-wrong value gives 'unsupported browser type: X' instead). This fires when browser options exist but the mandatory type was not declared.","triggerScenarios":"Exporting options.browser = { headless: true } without type; setting only env tuning vars (K6_BROWSER_HEADLESS etc.) while the scenario options carry no type; misspelling the key ('Type', 'browserType') or nesting it incorrectly so the map k6 receives has no 'type' key.","commonSituations":"Users adding headless/env tweaks to an options block that never had a type; restructured options where browser options moved between top-level and scenario scope; generated config from older k6 examples.","solutions":["Add type: 'chromium' inside the browser options at the right nesting: scenarios.ui.options.browser.type = 'chromium'","Double-check the exact key and nesting against the working snippet in the docs; the value must be the literal string 'chromium'","If you meant to run without a local browser, use the WS-endpoint configuration instead of dropping type"],"exampleFix":"// before\nexport const options = {\n  scenarios: { ui: { options: { browser: { headless: true } } } },\n};\n\n// after\nexport const options = {\n  scenarios: { ui: { options: { browser: { type: 'chromium', headless: true } } } },\n};","handlingStrategy":"validation","validationCode":"// Fail loudly at parse time instead of deep inside options parsing:\nconst browserOpts = { headless: true, ...overrides };\nif (!('type' in browserOpts) || browserOpts.type !== 'chromium') {\n  throw new Error(\"browser options must include type: 'chromium'\");\n}","typeGuard":"function isValidBrowserOptions(o) {\n  return o != null && typeof o === 'object' && o.type === 'chromium';\n}","tryCatchPattern":null,"preventionTips":["Copy the canonical options block from the k6 docs whenever you touch browser options","The only supported type value today is the exact string 'chromium' — no 'chrome', no defaults","Keep one shared module exporting the validated browser options instead of repeating them per scenario"],"tags":["browser","configuration","browser-options","argument-validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}