starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.71k stars 388 forks source link

Incorrect decode error #225

Closed surfskidude closed 1 year ago

surfskidude commented 1 year ago

I believe I got an incorrect decode error. I got the following error: type mismatch for field 'timestamp' at offset 2, varint expected for type uint64, got bytes However, I uploaded the data to this protobuf decoder https://protogen.marcgravell.com/decode and the data does not include 'bytes'

I have attached the data and a test script. failed.zip

starwing commented 1 year ago

to parse your data to raw wire format it results:

0A (1: bytes) 06 (length: 6)
    76 31 2E 30 2E 30
12 (2: bytes) 1A (length: 26)
    0A (1: bytes) 16 (length: 22)
        44 65 76 69 63 65 20 43 6F 6E 74 72 6F 6C 2F 52 65 62 69 72 74 68
    70 (14: varint) 01
28 (5: varint) 01

So, it seems like a Template type, not Payload type.

To change the type in test.lua from Payload to Payload.Template, it outputs:

{
  is_definition = true,
  metrics = {
    {
      boolean_value = true,
      name = "Device Control/Rebirth",
      value = "boolean_value"
    } --[[table: 000001E8E79E6CE0]]
  } --[[table: 000001E8E79E6CA0]],
  version = "v1.0.0"
} --[[table: 000001E8E79E7460]]
surfskidude commented 1 year ago

Yes, you are correct. Sorry for the noise.