grafana/k6 · error

failed to create request from request metadatas

Error message

failed to create request from request metadatas: %w

What it means

Wrapped error from IngestRequestMetadatasBatch: converting the batch of request metadata into the protobuf request (newBatchCreateRequestMetadatasRequest) failed before the gRPC call was made — typically malformed metadata such as invalid timestamps or fields that cannot be encoded.

Solutions

  1. Inspect the wrapped error to find which metadata field failed conversion
  2. Ensure request metadata values (URLs, method, timestamps) are well-formed before enqueueing them
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/cloudapi/insights/client.go:177 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/f07226024aebfc33. Report an issue: GitHub.

Appendix: 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 01ffac6f24)