grafana/k6 · error
can't serialise request object to protocol buffer: %w
Error message
can't serialise request object to protocol buffer: %w
What it means
Stream.Send could not unmarshal the provided message bytes into a dynamic message for the stream's input type. The payload JS object was serialized and then protojson-decoded against the method descriptor; unknown fields, wrong field types, or invalid enum names that do not match the input schema cause this. The message is never put on the wire.
Source
Thrown at internal/lib/netext/grpcext/stream.go:120
err = json.Unmarshal(raw, &back)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal the message: %w", err)
}
return back, err
}
// CloseSend closes the stream
func (s *Stream) CloseSend() error {
return s.raw.CloseSend()
}
// BuildMessage builds a message from the input
func (s *Stream) buildMessage(b []byte) (*dynamicpb.Message, error) {
msg := dynamicpb.NewMessage(s.methodDescriptor.Input())
if err := s.unmarshaler.Unmarshal(b, msg); err != nil {
return nil, fmt.Errorf("can't serialise request object to protocol buffer: %w", err)
}
return msg, nil
}
// Send sends the message to the stream
func (s *Stream) Send(b []byte) error {
msg, err := s.buildMessage(b)
if err != nil {
return err
}
return s.raw.SendMsg(msg)
}
View on GitHub (pinned to 01ffac6f24)
Solutions
- Shape the payload to match the stream's request message schema exactly (names, nesting, types)
- Validate enum names and required fields against the .proto definition
- Log the serialized payload before calling send() to spot mismatches
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/lib/netext/grpcext/stream.go:120 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/13a735ae59c22e96.
Report an issue: GitHub.