{"record":{"id":"f07226024aebfc33","repo":"grafana/k6","slug":"failed-to-create-request-from-request-metadatas","errorCode":null,"errorMessage":"failed to create request from request metadatas: %w","messagePattern":"failed to create request from request metadatas: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/insights/client.go","lineNumber":177,"sourceCode":"\treturn nil\n}\n\n// IngestRequestMetadatasBatch ingests a batch of request metadatas.\nfunc (c *Client) IngestRequestMetadatasBatch(ctx context.Context, requestMetadatas RequestMetadatas) error {\n\tc.connMu.RLock()\n\tclosed := c.conn == nil\n\tc.connMu.RUnlock()\n\tif closed {\n\t\treturn ErrClientClosed\n\t}\n\n\tif len(requestMetadatas) < 1 {\n\t\treturn nil\n\t}\n\n\treq, err := newBatchCreateRequestMetadatasRequest(requestMetadatas)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create request from request metadatas: %w\", err)\n\t}\n\n\tctx, cancel := context.WithTimeout(ctx, c.cfg.Timeout)\n\tdefer cancel()\n\t_, err = c.client.BatchCreateRequestMetadatas(ctx, req)\n\tif err != nil {\n\t\tst := status.Convert(err)\n\t\treturn fmt.Errorf(\"failed to ingest request metadatas batch: code=%s, msg=%s\", st.Code().String(), st.Message())\n\t}\n\n\treturn nil\n}\n\n// Close closes the client.\nfunc (c *Client) Close() error {\n\tc.connMu.Lock()\n\tdefer c.connMu.Unlock()\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/insights/client.go#L159-L195","documentation":"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.","triggerScenarios":"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.","commonSituations":"A regression or version skew after adding a new protocol to insights collection; forked/custom builds adding label types without updating setProtocolLabels.","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"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Go: only HTTP-labelled request metadata can be mapped today (mappers.go setProtocolLabels)\nfunc isHTTPProtocolLabels(l insightsclient.ProtocolLabels) bool {\n    _, ok := l.(insightsclient.ProtocolHTTPLabels)\n    return ok\n}\n\nfiltered := rm[:0]\nfor _, m := range rm {\n    if isHTTPProtocolLabels(m.ProtocolLabels) {\n        filtered = append(filtered, m)\n    }\n}","tryCatchPattern":"if err := client.IngestRequestMetadatasBatch(ctx, batch); err != nil {\n    if strings.Contains(err.Error(), \"failed to create request from request metadatas\") {\n        // local mapping failure (unknown protocol labels) - retrying will not help; update k6 / filter the batch\n    }\n}","preventionTips":["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"],"tags":["cloud","insights","grpc","protocol-labels","internal"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}