google / webrisk

Apache License 2.0
65 stars 33 forks source link

JSON message is not unmarshalling correctly into protobuf message #16

Open thatjiaozi opened 4 years ago

thatjiaozi commented 4 years ago

It seems that when the database is updated and receives a new version token the unmarshalling is not done correctly.

Expected: Cg0IARAGGAEiAzAwMTABEP/7BhoCGAnR73ir
unmarshalled: [10 13 8 1 16 6 24 1 34 3 48 48 49 48 1 16 255 251 6 26 2 24 9 209 239 120 171]

This could be an issue with https://godoc.org/github.com/golang/protobuf/jsonpb itself.

I created the branch json-marshalling-bug for future investigation, meanwhile i am going to revert the changes that introduced this bug.

jiayuanmasc commented 4 years ago

I believe the issue is due to that versionToken is not base64 encoded here. The error message from the API looks like

"error": {
    "code": 400,
    "message": "Invalid value at 'version_token' (TYPE_BYTES), Base64 decoding failed for \"\n\r\b\u0001\u0010\u0006\u0018\u0001\"\u00030010\u0001\u0010  \u0007\u001a\u0002\u0018\u0003 h 8\"",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "version_token",
            "description": "Invalid value at 'version_token' (TYPE_BYTES), Base64 decoding failed for \"\n\r\b\u0001\u0010\u0006\u0018\u0001\"\u00030010\u0001\u0010  \u0007\u001a\u0002\u0018\u0003 h 8\""
          }
        ]
      }
    ]
  }