{"record":{"id":"13a735ae59c22e96","repo":"grafana/k6","slug":"can-t-serialise-request-object-to-protocol-buffer","errorCode":null,"errorMessage":"can't serialise request object to protocol buffer: %w","messagePattern":"can't serialise request object to protocol buffer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lib/netext/grpcext/stream.go","lineNumber":120,"sourceCode":"\n\terr = json.Unmarshal(raw, &back)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal the message: %w\", err)\n\t}\n\n\treturn back, err\n}\n\n// CloseSend closes the stream\nfunc (s *Stream) CloseSend() error {\n\treturn s.raw.CloseSend()\n}\n\n// BuildMessage builds a message from the input\nfunc (s *Stream) buildMessage(b []byte) (*dynamicpb.Message, error) {\n\tmsg := dynamicpb.NewMessage(s.methodDescriptor.Input())\n\tif err := s.unmarshaler.Unmarshal(b, msg); err != nil {\n\t\treturn nil, fmt.Errorf(\"can't serialise request object to protocol buffer: %w\", err)\n\t}\n\n\treturn msg, nil\n}\n\n// Send sends the message to the stream\nfunc (s *Stream) Send(b []byte) error {\n\tmsg, err := s.buildMessage(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn s.raw.SendMsg(msg)\n}\n","sourceCodeStart":102,"sourceCodeEnd":135,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/lib/netext/grpcext/stream.go#L102-L135","documentation":"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.","triggerScenarios":"Thrown at internal/lib/netext/grpcext/stream.go:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}