grafana/k6 · error
failed to create request from request metadatas: %w
Error message
failed to create request from request metadatas: %w
What it means
Before sending a batch, IngestRequestMetadatasBatch converts internal RequestMetadatas to the proto batch (internal/cloudapi/insights/client.go:176-179). The mapper (insights/mappers.go:11-67) only knows ProtocolHTTPLabels; any other ProtocolLabels value returns 'unknown protocol labels type', which bubbles up wrapped as this error. So the failure is local data conversion - the RPC was never attempted - and today it indicates a protocol the insights mapper does not handle.
Source
Thrown at internal/cloudapi/insights/client.go:177
return nil
}
// IngestRequestMetadatasBatch ingests a batch of request metadatas.
func (c *Client) IngestRequestMetadatasBatch(ctx context.Context, requestMetadatas RequestMetadatas) error {
c.connMu.RLock()
closed := c.conn == nil
c.connMu.RUnlock()
if closed {
return ErrClientClosed
}
if len(requestMetadatas) < 1 {
return nil
}
req, err := newBatchCreateRequestMetadatasRequest(requestMetadatas)
if err != nil {
return fmt.Errorf("failed to create request from request metadatas: %w", err)
}
ctx, cancel := context.WithTimeout(ctx, c.cfg.Timeout)
defer cancel()
_, err = c.client.BatchCreateRequestMetadatas(ctx, req)
if err != nil {
st := status.Convert(err)
return fmt.Errorf("failed to ingest request metadatas batch: code=%s, msg=%s", st.Code().String(), st.Message())
}
return nil
}
// Close closes the client.
func (c *Client) Close() error {
c.connMu.Lock()
defer c.connMu.Unlock()
View on GitHub (pinned to 93accf6570)
Solutions
- Update k6 - upstream mappers cover the protocols supported for insights in each release
- If it persists on the latest release, report an issue naming the protocol used (the TODO at mappers.go:52 tracks unmapped protocols)
- As a workaround, run without insights (e.g. plain 'k6 run' or cloud output without insights) until fixed
Defensive patterns
Strategy: type-guard
Type guard
// Go: only HTTP-labelled request metadata can be mapped today (mappers.go setProtocolLabels)
func isHTTPProtocolLabels(l insightsclient.ProtocolLabels) bool {
_, ok := l.(insightsclient.ProtocolHTTPLabels)
return ok
}
filtered := rm[:0]
for _, m := range rm {
if isHTTPProtocolLabels(m.ProtocolLabels) {
filtered = append(filtered, m)
}
} Try / catch
if err := client.IngestRequestMetadatasBatch(ctx, batch); err != nil {
if strings.Contains(err.Error(), "failed to create request from request metadatas") {
// local mapping failure (unknown protocol labels) - retrying will not help; update k6 / filter the batch
}
} Prevention
- Keep k6 updated so protocol-label mappers match the protocols your scripts emit
- Treat this error as a bug signal - it means an unsupported protocol reached the insights path
- When extending ProtocolLabels in forks, extend setProtocolLabels in the same change
When it happens
Trigger: Request metadata carrying a non-HTTP protocol labels type (gRPC, WebSocket, browser) reaching the insights batch builder; a newer k6 emitting a new protocol label type that this build's mapper switch (mappers.go:51-64) does not cover.
Common situations: A regression or version skew after adding a new protocol to insights collection; forked/custom builds adding label types without updating setProtocolLabels.
Related errors
- failed to create dial options: %w
- failed to dial: %w
- failed to ingest request metadatas batch: code=%s, msg=%s
- failed to load TLS credentials from file: %w
- failed to create retry interceptors: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/f07226024aebfc33.
Report an issue: GitHub.