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

Invalid field number 0 when decoding binary data #333

Open
VincentRPS opened this issue Dec 30, 2022 · 3 comments
Open

Invalid field number 0 when decoding binary data #333

VincentRPS opened this issue Dec 30, 2022 · 3 comments
Assignees
Labels
Kind:Needs More Info Needs more information to investigate.

Comments

@VincentRPS
Copy link

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;
}
@whatyouhide
Copy link
Collaborator

Thanks for the report! Can you provide a minimal set of steps to reproduce the error? The Protobuf schema helps, but I'd like to have a small script that reproduces this 🙃

@whatyouhide whatyouhide added the Kind:Needs More Info Needs more information to investigate. label Dec 30, 2022
@VincentRPS
Copy link
Author

VincentRPS commented Jul 24, 2023

Thanks for the report! Can you provide a minimal set of steps to reproduce the error? The Protobuf schema helps, but I'd like to have a small script that reproduces this 🙃

sorry for the late response, was busy with some things. All I did was run protoc --elixir_out=./lib {the_proto}.proto like in the example. I don't really know what could be causing this.

I recently just reinstalled both Erlang and Elixir and even that didn't do anything. I am on Windows but I really doubt that's is the problem. It seems like the problem is occurring on this line (Protobuf.Decoder:45-48):

if field_number != 0 do
  handle_field(rest, field_number, wire_type, message, props)
else
  raise Protobuf.DecodeError, message: "invalid field number 0 when decoding binary data"
end

@whatyouhide
Copy link
Collaborator

Okay the first step here will be to see if we can reproduce this @savhappy 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind:Needs More Info Needs more information to investigate.
Projects
None yet
Development

No branches or pull requests

3 participants