JuliaIO / ProtoBuf.jl

Julia protobuf implementation
Other
205 stars 55 forks source link

ERROR: has no field __protobuf_jl_internal_defaultset #157

Closed tbonza closed 2 years ago

tbonza commented 3 years ago

Using a .proto file like the following, I'm unable to generate Julia code using v0.10.0 or v0.9.1 There's no issue with v0.9.0.

syntax = "proto3";

package mahata;

message Keyphrase {
    string keyphrase = 1;
    float score = 2;
    Topics topics = 3;
}

message Keyphrases {
    repeated Keyphrase keyps = 1;
}

// Candidate is a generic instance format
// used across various data sources.
message Candidate {
    string uuid = 1;
    string theme = 2;
    string body = 3;
    Keyphrases prep_theme = 4;
    Keyphrases prep_body = 5;
}

The error message I receive when running my test suite using v0.10.0 is the following:

protobufs: Error During Test at /Users/tylebrow/code/dit/test/fileio.jl:113
  Got exception outside of a @test
  type Candidate has no field __protobuf_jl_internal_defaultset
  Stacktrace:
   [1] getproperty(::Dit.Mahata.Candidate, ::Symbol) at /Users/tylebrow/code/dit/src/edmate_pb.jl:195
   [2] setproperty!(::Dit.Mahata.Candidate, ::Symbol, ::String) at /Users/tylebrow/.julia/packages/ProtoBuf/NJbMU/src/codec.jl:684
   [3] readproto(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Dit.Mahata.Candidate, ::ProtoBuf.ProtoMeta) at /Users/tylebrow/.julia/packages/ProtoBuf/NJbMU/src/codec.jl:532
   [4] read_lendelim_obj(::IOStream, ::Dit.Mahata.Candidate, ::ProtoBuf.ProtoMeta, ::typeof(ProtoBuf.readproto)) at /Users/tylebrow/.julia/packages/ProtoBuf/NJbMU/src/codec.jl:445
   [5] read_field(::IOStream, ::Candidates, ::ProtoBuf.ProtoMetaAttribs, ::UInt64, ::Nothing) at /Users/tylebrow/.julia/packages/ProtoBuf/NJbMU/src/codec.jl:489
   [6] readproto(::IOStream, ::Candidates, ::ProtoBuf.ProtoMeta) at /Users/tylebrow/.julia/packages/ProtoBuf/NJbMU/src/codec.jl:527
   [7] readproto(::IOStream, ::Candidates) at /Users/tylebrow/.julia/packages/ProtoBuf/NJbMU/src/codec.jl:511
   [8] readpb(::Type{T} where T, ::String) at /Users/tylebrow/code/dit/src/fileio.jl:27
   [9] top-level scope at /Users/tylebrow/code/dit/test/fileio.jl:115
   [10] top-level scope at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1115
   [11] top-level scope at /Users/tylebrow/code/dit/test/fileio.jl:115
   [12] include(::String) at ./client.jl:457
   [13] top-level scope at /Users/tylebrow/code/dit/test/runtests.jl:2
   [14] include(::String) at ./client.jl:457
   [15] top-level scope at none:6
   [16] eval(::Module, ::Any) at ./boot.jl:331
   [17] exec_options(::Base.JLOptions) at ./client.jl:272
   [18] _start() at ./client.jl:506

My interpretation of this error message is that I'm having an issue with readproto due to a missing field in the Julia files I've generated from the above protobuf.

tanmaykm commented 3 years ago

Should work with v0.10.0 or v0.9.1. But that needs re-generating the julia code from proto files using the updated ProtoBuf.jl. (In hindsight, should probably have bumped minor version instead of patch version for #150)

tbonza commented 3 years ago

After re-generating the julia code from proto files using v0.10.0, I'm still getting the error. I wondered if the protoc version may be out of date, I'm using

protoc --version                                                                                                                                                                          
libprotoc 3.14.0
tanmaykm commented 3 years ago

That's strange. Can you verify if the generated structs are something like this? Basically they should have three fields as in the linked example.

If not, then I suspect the old version of ProtoBuf is somehow getting invoked, possibly because of some old paths and environment variables.

tbonza commented 3 years ago

The generated structs are missing __protobuf_jl_internal_defaultset so instead I get

mutable struct Candidates <: ProtoType                                                           
    __protobuf_jl_internal_meta::ProtoMeta                                                       
    __protobuf_jl_internal_values::Dict{Symbol,Any}

I've been using Homebrew to install protobuf so the issue may be there. I've been using this package for the past year without any issues other than needing to occasionally re-generate Julia files from the proto.

tanmaykm commented 3 years ago

I would suggest checking that correct version of these two should be available via PATH environment:

tbonza commented 3 years ago

In this case, I'm developing a package so I'm managing my environment via julia --project=. from within the package directory. Using v0.10.0 and the package manager, my Project.toml includes ProtoBuf = "3349acd9-ac6a-5e09-bcdb-63829b23a429".

What are some helpful next steps? I could do a pull request with a test that replicates the issue.

Drvi commented 2 years ago

This issue is really old and ProtoBuf.jl 1.0 has been release recently... closing for now, but do reach out if you encounter problems with the new version. Cheers.