{"record":{"id":"9d21f219394f0bff","repo":"grafana/k6","slug":"invalid-websocket-endpoint-q-scheme-must-be-ws-o","errorCode":null,"errorMessage":"invalid WebSocket endpoint %q: scheme must be ws or wss, got %q","messagePattern":"invalid WebSocket endpoint %q: scheme must be ws or wss, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/chromium/browser_type.go","lineNumber":164,"sourceCode":"\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\n// its lifecycle.\n//\n// context.background() is used when connecting to an instance of chromium. The\n// connection lifecycle should be handled by the k6 event system.","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/chromium/browser_type.go#L146-L182","documentation":"The URL in wsEndpoint parsed successfully but its scheme is neither ws nor wss — e.g. http:// or https://. validateWSEndpoint rejects it before any connection attempt; both the endpoint and offending scheme are echoed.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace http:// with ws:// (or https:// with wss://) in the endpoint","Get the correct webSocketDebuggerUrl from http://host:port/json/version"],"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"}