grafana/k6 · error

server returned %d (%s)

Error message

server returned %d (%s)

What it means

Returned by checkStatusCode (a generic sentinel-style guard, not a wrapper — no %w) when an HTTP response's status falls outside 200–299; '%d' is the status code and '%s' its lowercased reason text. It guards both the presigned-URL request and the upload request in RemoteFilePersister. It fires when the remote service rejects the call: expired/invalid presigned URL (403), auth failure (401), payload too large (413), or server errors (5xx).

Source

Thrown at internal/js/modules/k6/browser/storage/file_persister.go:248

	}

	req, err := http.NewRequestWithContext(
		ctx,
		psu.Method,
		psu.PresignedURL,
		&form,
	)
	if err != nil {
		return nil, fmt.Errorf("creating new request: %w", err)
	}
	req.Header.Set("Content-Type", fw.FormDataContentType())

	return req, nil
}

func checkStatusCode(resp *http.Response) error {
	if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
		return fmt.Errorf("server returned %d (%s)", resp.StatusCode, strings.ToLower(http.StatusText(resp.StatusCode)))
	}

	return nil
}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Retry the whole persist to obtain a fresh presigned URL (they expire quickly)
  2. Verify cloud credentials and auth headers are valid
  3. Reduce artifact size if hitting 413 limits
  4. Use the status code/reason in the message to pinpoint auth vs size vs server issues
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/storage/file_persister.go:248 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/5a456cc82a4770bd. Report an issue: GitHub.