{"record":{"id":"139cd196c5eec0c6","repo":"grafana/k6","slug":"failed-to-marshal-the-message-w","errorCode":null,"errorMessage":"failed to marshal the message: %w","messagePattern":"failed to marshal the message: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lib/netext/grpcext/stream.go","lineNumber":98,"sourceCode":"//\n//\tmessage Point {\n//\t   double x = 1;\n//\t\t  double y = 2;\n//\t\t  double z = 3;\n//\t}\n//\n// 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","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/lib/netext/grpcext/stream.go#L80-L116","documentation":"protojson failed to marshal a dynamic response message back to JSON during conversion. k6 converts dynamic protobuf messages to plain Go values via a JSON round-trip so JS property access works; this fires when the message contains data protojson refuses to serialize (e.g. google.protobuf.Any with an unresolvable type or invalid UTF-8 in a string field).","triggerScenarios":"Thrown at internal/lib/netext/grpcext/stream.go:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that response string fields contain valid UTF-8 and Any fields reference resolvable types","Ensure the client's type resolver knows all message types involved (use reflection from the live server or a complete proto bundle)","Capture the actual response server-side and validate it against the schema"],"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"}