{"record":{"id":"87b8dbd49a155c04","repo":"grafana/k6","slug":"unable-to-convert-response-object-to-json-w","errorCode":null,"errorMessage":"unable to convert response object to JSON: %w","messagePattern":"unable to convert response object to JSON: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lib/netext/grpcext/conn.go","lineNumber":199,"sourceCode":"\t\tsterr := status.Convert(err)\n\t\tresponse.Status = sterr.Code()\n\n\t\t// (rogchap) when you access a JSON property in Sobek, you are actually accessing the underling\n\t\t// Go type (struct, map, slice etc); because these are dynamic messages the Unmarshaled JSON does\n\t\t// not map back to a \"real\" field or value (as a normal Go type would). If we don't marshal and then\n\t\t// unmarshal back to a map, you will get \"undefined\" when accessing JSON properties, even when\n\t\t// JSON.Stringify() shows the object to be correctly present.\n\n\t\traw, _ := marshaler.Marshal(sterr.Proto())\n\t\terrMsg := make(map[string]any)\n\t\t_ = json.Unmarshal(raw, &errMsg)\n\t\tresponse.Error = errMsg\n\t}\n\n\tif resp != nil && !req.DiscardResponseMessage {\n\t\tmsg, err := convert(marshaler, resp)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to convert response object to JSON: %w\", err)\n\t\t}\n\n\t\tresponse.Message = msg\n\t}\n\treturn &response, nil\n}\n\n// NewStream creates a new gRPC stream.\nfunc (c *Conn) NewStream(\n\tctx context.Context,\n\treq StreamRequest,\n\topts ...grpc.CallOption,\n) (*Stream, error) {\n\tctx = metadata.NewOutgoingContext(ctx, req.Metadata)\n\n\tctx = withRPCState(ctx, &rpcState{tagsAndMeta: req.TagsAndMeta})\n\n\tstream, err := c.raw.NewStream(ctx, &grpc.StreamDesc{","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/lib/netext/grpcext/conn.go#L181-L217","documentation":"After a gRPC call, the response dynamic message could not be marshaled back to JSON by protojson. Dynamic messages do not map onto real Go types, so k6 round-trips them through JSON to make fields accessible from JS; this error means the response message itself violated protojson marshaling rules (e.g. an Any without a resolvable type). Fires after the RPC completes, during result conversion.","triggerScenarios":"Thrown at internal/lib/netext/grpcext/conn.go:199 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the server response matches the reflected proto schema, especially google.protobuf.Any fields that need resolvable type URLs","Ensure the Client was created from a reflection-capable server so all types in the response are known","If the schema uses uncommon well-known types, load the proto definitions from a local bundle instead of reflection"],"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-14T05:17:10.506Z"}