{"record":{"id":"a4d3aa549235d823","repo":"grafana/k6","slug":"invalid-websocket-endpoint-q-w","errorCode":null,"errorMessage":"invalid WebSocket endpoint %q: %w","messagePattern":"invalid WebSocket endpoint %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/chromium/browser_type.go","lineNumber":160,"sourceCode":"\t\t\tTimeout: browserOpts.Timeout,\n\t\t}\n\t\treturn nil, fmt.Errorf(\"%w\", err)\n\t}\n\n\treturn bp, nil\n}\n\n// validateWSEndpoint returns an error if wsEndpoint is not a usable CDP\n// WebSocket URL, catching common mistakes (an empty value, a non-ws scheme,\n// a missing host, etc.) before we attempt to connect.\nfunc validateWSEndpoint(wsEndpoint string) error {\n\tif strings.TrimSpace(wsEndpoint) == \"\" {\n\t\treturn errors.New(\"WebSocket endpoint cannot be empty\")\n\t}\n\n\tu, err := url.Parse(wsEndpoint)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid WebSocket endpoint %q: %w\", wsEndpoint, err)\n\t}\n\n\tif u.Scheme != \"ws\" && u.Scheme != \"wss\" {\n\t\treturn fmt.Errorf(\n\t\t\t\"invalid WebSocket endpoint %q: scheme must be ws or wss, got %q\", wsEndpoint, u.Scheme,\n\t\t)\n\t}\n\n\tif u.Hostname() == \"\" {\n\t\treturn fmt.Errorf(\"invalid WebSocket endpoint %q: host is missing\", wsEndpoint)\n\t}\n\n\treturn nil\n}\n\n// Connect attaches k6 browser to an existing browser instance.\n//\n// vuCtx is the context coming from the VU itself. The k6 vu/iteration controls","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/chromium/browser_type.go#L142-L178","documentation":"The wsEndpoint string passed to chromium.connectOverCDP() is not a parseable URL. net/url.Parse failed on the raw string, so it is echoed verbatim; typical causes are stray characters, spaces, or a missing scheme delimiter.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:160 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a well-formed CDP WebSocket URL: ws://host:port/devtools/browser/<id>","Verify the endpoint with a curl of http://host:port/json/version","Trim whitespace and copy the URL exactly from Chrome's output"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}