{"record":{"id":"9ab710a1648abb2a","repo":"grafana/k6","slug":"failed-to-unmarshal-the-message-w","errorCode":null,"errorMessage":"failed to unmarshal the message: %w","messagePattern":"failed to unmarshal the message: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lib/netext/grpcext/stream.go","lineNumber":105,"sourceCode":"// and a value like this:\n// msg := Point{X: 6, Y: 4, Z: 0}\n// would result in JSON output:\n// {\"x\":6,\"y\":4}\n// rather than the desired:\n// {\"x\":6,\"y\":4,\"z\":0}\nfunc convert(marshaler protojson.MarshalOptions, msg *dynamicpb.Message) (any, error) {\n\t// TODO(olegbespalov): add the test that checks that message is not nil\n\n\traw, err := marshaler.Marshal(msg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal the message: %w\", err)\n\t}\n\n\tvar back any\n\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","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/lib/netext/grpcext/stream.go#L87-L123","documentation":"The JSON produced by marshaling a dynamic protobuf message could not be unmarshaled into a generic Go value. This is the second half of the convert round-trip; failing here indicates a mismatch between what protojson emitted and what encoding/json accepts (e.g. precision or number-format edge cases), and is essentially an internal/k6-side anomaly rather than a user input error.","triggerScenarios":"Thrown at internal/lib/netext/grpcext/stream.go:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Upgrade k6 to the latest version where conversion edge cases may be fixed","Report the failing message type and payload to the k6 issue tracker","As a workaround, handle the message's raw response on the server side instead of relying on the converted object"],"exampleFix":null,"handlingStrategy":"fallback","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"}