{"record":{"id":"4ead076f2c18b4af","repo":"grafana/k6","slug":"unsupported-response-status-s","errorCode":null,"errorMessage":"unsupported response status: %s","messagePattern":"unsupported response status: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/netext/httpext/request.go","lineNumber":279,"sourceCode":"\t\t\t\t}\n\t\t\t\treturn http.ErrUseLastResponse\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\n\treqCtx, cancelFunc := context.WithTimeout(ctx, preq.Timeout)\n\tdefer cancelFunc()\n\tmreq := preq.Req.WithContext(reqCtx)\n\tres, resErr := client.Do(mreq) //nolint:gosec\n\n\t// TODO(imiric): It would be safer to check for a writeable\n\t// response body here instead of status code, but those are\n\t// wrapped in a read-only body when using client timeouts and are\n\t// unusable until https://github.com/golang/go/issues/31391 is fixed.\n\tif res != nil && res.StatusCode == http.StatusSwitchingProtocols {\n\t\t_ = res.Body.Close()\n\t\treturn nil, fmt.Errorf(\"unsupported response status: %s\", res.Status)\n\t}\n\n\tif resErr == nil {\n\t\tresp.Body, resErr = readResponseBody(state, preq.ResponseType, res, resErr)\n\t\tif resErr != nil && errors.Is(resErr, context.DeadlineExceeded) {\n\t\t\t// TODO This can be more specific that the timeout happened in the middle of the reading of the body\n\t\t\tresErr = NewK6Error(requestTimeoutErrorCode, requestTimeoutErrorCodeMsg, resErr)\n\t\t}\n\t}\n\tfinishedReq := tracerTransport.processLastSavedRequest(wrapDecompressionError(resErr))\n\tif finishedReq != nil {\n\t\tupdateK6Response(resp, finishedReq)\n\t}\n\n\tif resErr == nil {\n\t\tif preq.ActiveJar != nil {\n\t\t\tif rc := res.Cookies(); len(rc) > 0 {\n\t\t\t\tpreq.ActiveJar.SetCookies(res.Request.URL, rc)","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/netext/httpext/request.go#L261-L297","documentation":"Raised by MakeRequest when the server responds with HTTP 101 Switching Protocols, which the plain HTTP client does not support (protocol upgrades like WebSockets must use the dedicated ws module). k6 closes the body and rejects the response.","triggerScenarios":"Thrown at lib/netext/httpext/request.go:279 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the k6/ws or k6/net/grpc module for protocol-upgrade endpoints","Verify the URL points to a plain HTTP endpoint and not a WebSocket endpoint (ws:// / wss://)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}