graphql-platform
graphql-platform copied to clipboard
Encoded ID with empty string value fails with ArgumentNullException
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
An empty string is a valid string. If the value part of a HotChocolate ID is of type string then it should serialize and deserialize without error.
For example, type name "MyType" with id value "" is base64-encoded as "MyType\nd" to "TXlUeXBlCmQ=". It base64-decodes back to "MyType\nd",
Deserializing through HotChocolate.Types.Relay.IdSerializer causes an exception however:
Unhandled exception. System.ArgumentNullException: Array cannot be null. (Parameter 'bytes')
at System.Text.Encoding.GetString(Byte* bytes, Int32 byteCount)
at HotChocolate.Types.Relay.IdSerializer.CreateString(Span`1 serialized)
at HotChocolate.Types.Relay.IdSerializer.Deserialize(String serializedId)
Steps to reproduce
IIdSerializer serializer = new IdSerializer(false);
var ser = serializer.Serialize(new NameString("MySchema"), new NameString("MyType"), "");
Console.WriteLine(ser);
var deser = serializer.Deserialize(ser);
Console.WriteLine(deser);
Relevant log output
No response
Additional Context?
No response
Product
Hot Chocolate
Version
12.9.0
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.