protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Invalid field number 0 when decoding binary data

Open VincentRPS opened this issue 1 year ago • 3 comments

I am currently trying to use Protobuf in one of my elixir projects but I keep getting this error:

** (Protobuf.DecodeError) invalid field number 0 when decoding binary data
    (protobuf 0.11.0) lib/protobuf/decoder.ex:48: Protobuf.Decoder.build_message/3
    (protobuf 0.11.0) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
    (protobuf 0.11.0) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
    (protobuf 0.11.0) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
    (protobuf 0.11.0) lib/protobuf/decoder.ex:176: Protobuf.Decoder.handle_value/6
    (protobuf 0.11.0) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
    (protobuf 0.11.0) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
    (protobuf 0.11.0) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
--elixir_out: protoc-gen-elixir: Plugin failed with status code 1.

I've looked everywhere for a solution but seemingly can't find one.

This is my Protobuf code:

syntax = "proto3";

import "google/protobuf/any.proto";

package derailed.grpc;

service Guild {
    rpc publish (Publ) returns (Publr) {};
    rpc get_guild_info (GetGuildInfo) returns (RepliedGuildInfo) {};
}

message Message {
    string event = 1;
    map<string, google.protobuf.Any> data = 2;
}

message Publ {
    string guild_id = 1;
    Message message = 2;
}

message Publr {
    string message = 1;
}

message GetGuildInfo {
    string guild_id = 1;
}

message RepliedGuildInfo {
    int32 presences = 1;
}

VincentRPS avatar Dec 30 '22 06:12 VincentRPS