You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of protobuf and what language are you using?
Version: main/v29.2
Language: C#
What operating system (Linux, Windows, ...) and version?
Windows 10 22H2 What runtime / compiler are you using (e.g., python version or gcc version)
Visual Studio 2022 What did you do?
Steps to reproduce the behavior:
The "Any" type fields do not accept null values for packing; only an empty object instantiated with new Any() can be passed to represent a null value.
An empty "Any" object is represented as {"@type": "", "@value": ""}.
The current C# JsonFormatter and JsonParser both do not accept this input value, and both throw an error: Type registry has no descriptor for type name ''.
For example:
var rep = new MsgFromProtoFile(); // IMessage instance
rep.SomeAnyField = Any.Pack(new MyAnyField{ strField= "string",
anyField= new Any() // empty Any object, this will be {"@type": "", "@value": ""}
});
var tr = TypeRegistry.FromMessages(MyAnyField.Descriptor);
var json_parser = new JsonParser(JsonParser.Settings.Default.WithTypeRegistry(tr));
var formater = new JsonFormatter(new JsonFormatter.Settings(true).WithTypeRegistry(tr));
var json_text = formater.Format(rep); // throw exception as above
var rep0 = json_parser.Parse<MsgFromProtoFile>(json_text); // throw exception as above
What did you expect to see
formater return json text with null value, ex: {"anyField": null}
parser return empty Any object as expect, even if {"@type": "", "@value": ""}
What did you see instead?
throw an error: Type registry has no descriptor for type name ''.
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
In the Golang library, an empty "Any" object represented as {"@type": "", "@value": ""} can be processed normally.
It is recommended to handle this in the function MergeAny() of Google.Protobuf.JsonParser
What version of protobuf and what language are you using?
Version: main/v29.2
Language: C#
What operating system (Linux, Windows, ...) and version?
Windows 10 22H2
What runtime / compiler are you using (e.g., python version or gcc version)
Visual Studio 2022
What did you do?
Steps to reproduce the behavior:
The "Any" type fields do not accept null values for packing; only an empty object instantiated with new Any() can be passed to represent a null value.
An empty "Any" object is represented as {"@type": "", "@value": ""}.
The current C# JsonFormatter and JsonParser both do not accept this input value, and both throw an error: Type registry has no descriptor for type name ''.
For example:
What did you expect to see
formater return json text with null value, ex: {"anyField": null}
parser return empty Any object as expect, even if {"@type": "", "@value": ""}
What did you see instead?
throw an error: Type registry has no descriptor for type name ''.
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
In the Golang library, an empty "Any" object represented as {"@type": "", "@value": ""} can be processed normally.
It is recommended to handle this in the function MergeAny() of Google.Protobuf.JsonParser
to handle this in the function WriteAny() of Google.Protobuf.JsonFormatter
The text was updated successfully, but these errors were encountered: