ProtoBuf.jl icon indicating copy to clipboard operation
ProtoBuf.jl copied to clipboard

ERROR: has no field __protobuf_jl_internal_defaultset

Open tbonza opened this issue 4 years ago • 6 comments

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.

tbonza avatar Dec 01 '20 18:12 tbonza

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)

tanmaykm avatar Dec 05 '20 14:12 tanmaykm

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

tbonza avatar Dec 07 '20 16:12 tbonza

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.

tanmaykm avatar Dec 07 '20 16:12 tanmaykm

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.

tbonza avatar Dec 07 '20 16:12 tbonza

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

  • ProtoBuf/plugin/protoc-gen-julia - one from ProtoBuf v0.10.0 package folder
  • julia executable - one which has ProtoBuf.jl v0.10.0 installed (this could be set in the JULIA environment variable as well)

tanmaykm avatar Dec 07 '20 17:12 tanmaykm

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.

tbonza avatar Dec 14 '20 15:12 tbonza

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.

Drvi avatar Aug 18 '22 09:08 Drvi