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

AttributeError: 'google._upb._message.FileDescriptor' object has no attribute 'dependency' #19655

Open
odravison opened this issue Dec 13, 2024 · 0 comments

Comments

@odravison
Copy link

Hello guys,

I'm facing the error AttributeError: 'google._upb._message.FileDescriptor' object has no attribute 'dependency' while I tried to execute the code below:

from google.protobuf import message_factory
from my.package.to.generated_file_pb2 import CreateIntentsRequest

message_classes = message_factory.GetMessages([CreateIntentsRequest.DESCRIPTOR.file]) # the error is thrown here
my_proto_instance = message_classes['my.package.to.generated_file_pb2.CreateIntentsRequest']()

I don't know how Protobuf works and if I'm doing something wrong here.
I aim to create a filled message based on my compiled message in *_pb2.py files.

I've noted that FileDescriptor doesn't have dependency but dependencies instead

dependencies (list[FileDescriptor]): List of other :class:`FileDescriptor`
objects this :class:`FileDescriptor` depends on.

And the message_factory.GetMessages tries to access .dependency.

def _AddFile(file_proto):
for dependency in file_proto.dependency:
if dependency in file_by_name:
# Remove from elements to be visited, in order to cut cycles.
_AddFile(file_by_name.pop(dependency))
des_pool.Add(file_proto)

Am I missing something here? Is that a bug? Or just my lack of knowledge for this project?

Thank you in advanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant