grafana/k6 · error

unsupported response status: %s

Error message

unsupported response status: %s

What it means

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.

Source

Thrown at lib/netext/httpext/request.go:279

				}
				return http.ErrUseLastResponse
			}
			return nil
		},
	}

	reqCtx, cancelFunc := context.WithTimeout(ctx, preq.Timeout)
	defer cancelFunc()
	mreq := preq.Req.WithContext(reqCtx)
	res, resErr := client.Do(mreq) //nolint:gosec

	// TODO(imiric): It would be safer to check for a writeable
	// response body here instead of status code, but those are
	// wrapped in a read-only body when using client timeouts and are
	// unusable until https://github.com/golang/go/issues/31391 is fixed.
	if res != nil && res.StatusCode == http.StatusSwitchingProtocols {
		_ = res.Body.Close()
		return nil, fmt.Errorf("unsupported response status: %s", res.Status)
	}

	if resErr == nil {
		resp.Body, resErr = readResponseBody(state, preq.ResponseType, res, resErr)
		if resErr != nil && errors.Is(resErr, context.DeadlineExceeded) {
			// TODO This can be more specific that the timeout happened in the middle of the reading of the body
			resErr = NewK6Error(requestTimeoutErrorCode, requestTimeoutErrorCodeMsg, resErr)
		}
	}
	finishedReq := tracerTransport.processLastSavedRequest(wrapDecompressionError(resErr))
	if finishedReq != nil {
		updateK6Response(resp, finishedReq)
	}

	if resErr == nil {
		if preq.ActiveJar != nil {
			if rc := res.Cookies(); len(rc) > 0 {
				preq.ActiveJar.SetCookies(res.Request.URL, rc)

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use the k6/ws or k6/net/grpc module for protocol-upgrade endpoints
  2. Verify the URL points to a plain HTTP endpoint and not a WebSocket endpoint (ws:// / wss://)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/netext/httpext/request.go:279 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/4ead076f2c18b4af. Report an issue: GitHub.