Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent JSON <> Protobuf API standard #67

Open
punit-kulal opened this issue Aug 22, 2023 · 0 comments
Open

Inconsistent JSON <> Protobuf API standard #67

punit-kulal opened this issue Aug 22, 2023 · 0 comments

Comments

@punit-kulal
Copy link
Contributor

punit-kulal commented Aug 22, 2023

Bug

  • json message isn't serialised with correct Protobuf based JSON encoding standard.
  • Resulting in failure when sending JSON requests from valid protobuf encoded json string.

Context:

  1. Protobuf style guide states that JSON keys should be in camelCase, and protobuf keys/field names should be in snake_case.
  2. The standard for encoding Timestamp is to convert it into a string of RFC 3339.
  3. Thus, when a Request Payload is serialised. It uses CamelCase and also converts the timestamp/sent_time into a string.
  4. However, since raccoon uses standard encoding/json package to deserialise, it does not correctly deserialise camelCase keys of Json.
  5. It also fails to deserialise the date string.

Fix

  1. Start using protobuf's official encoding/protojson package for deserialisation.
  2. It adhere's to the style guide of protobuf, which supports deserialisation of both snake_case and camelCase keys in JSON.
  3. However, existing JSON contract will break since new json contract will expect sent_time to be of type string instead of an object {seconds: number, nanos: number}. This could be fixed by updating existing clients to use protobuf's json encoders instead of language's default json encoders.
@punit-kulal punit-kulal changed the title Inconsistent JSON API standard Inconsistent JSON <> Protobuf API standard Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Future
Development

No branches or pull requests

1 participant