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

MethodError: objects of type ProtoBuf.Codecs.BufferedVector{String} are not callable

Open xgdgsc opened this issue 3 months ago • 3 comments

┌ Error: grpc_async_stream_response: unexpected exception
│   exception =
│    MethodError: objects of type ProtoBuf.Codecs.BufferedVector{String} are not callable
│    The object of type `ProtoBuf.Codecs.BufferedVector{String}` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
└ @ gRPCClient ~/.julia/packages/gRPCClient/U2ltm/src/Streaming.jl:100

when the streaming response would be a struct like

struct Lines
    Lines::Vector{String}
    error::String
end

proto


message Line { string Line = 1; }

message Lines {
  repeated string Lines = 1;
  string error = 2;
}

Both types doesn' t work.

when return Line:

┌ Error: grpc_async_stream_response: unexpected exception
│   exception =
│    MethodError: objects of type String are not callable
│    The object of type `String` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
└ @ gRPCClient ~/.julia/packages/gRPCClient/U2ltm/src/Streaming.jl:100

xgdgsc avatar Dec 17 '25 08:12 xgdgsc

Turns out you cannot use same Line as struct name and Line in attributes. Other languages I used (python go) doesn' t have this issue. Changing attribute name works.

message Line { string line = 1; }

message Lines {
  repeated string lines = 1;
  string error = 2;
}

xgdgsc avatar Dec 17 '25 10:12 xgdgsc

Interesting. I'm not sure if this is an issue with gRPCClient or ProtoBuf. Maybe there is a scoping issue where if you use the module version of the autogenerated code this conflict will not happen?

csvance avatar Dec 17 '25 13:12 csvance

@xgdgsc with the above example are you able to use encode on Line when the inner name is also Line? If not, that would be something specific to ProtoBuf.jl.

csvance avatar Dec 17 '25 13:12 csvance

Closing as I think this is likely an issue with ProtoBuf.jl. All we do is call encode/decode via the public interface.

csvance avatar Jan 16 '26 15:01 csvance