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

Correct serialization of google::protobuf::Any #2

Open
tustvold opened this issue Sep 28, 2021 · 2 comments
Open

Correct serialization of google::protobuf::Any #2

tustvold opened this issue Sep 28, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@tustvold
Copy link
Collaborator

From https://developers.google.com/protocol-buffers/docs/proto3#json

If the Any contains a value that has a special JSON mapping, it will be converted as follows: {"@type": xxx, "value": yyy}. Otherwise, the value will be converted into a JSON object, and the "@type" field will be inserted to indicate the actual data type.

Currently Any is not special cased and is therefore not serialized/deserialized to/from this custom representation. This should be fixed

@tustvold tustvold added the bug Something isn't working label Sep 28, 2021
@alamb
Copy link
Contributor

alamb commented Dec 16, 2021

For what it is worth, I hit this today as well

Here is an example which might help

pbjson produces:

  "ReadSource": {
    "typeUrl": "type.googleapis.com/com.github.influxdata.idpe.storage.read.ReadSource",
    "value": "COLy2v2h1bG1qwEQl/Gxk7nbhPmzAQ=="
  },

When the binary value in Any is decoded, it looks like

org_id: 12351903361995815266
bucket_id: 12966447011416799383

When I manually changed my pbjson to look like this

  "ReadSource": {
    "@type": "type.googleapis.com/influxdata.platform.storage.read.ReadSource",
    "orgId": "12351903361995815266",
    "bucketId": "12966447011416799383"
  },
...

Then grpcurl was able to handle it

@therishidesai
Copy link

Running into this issue as well with an api that sends the data with the "@type" and unpacked data in the rest of the body. Is there any ideas on how to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants