-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Failure to serialize protos on re-run when proto2 syntax file has doubles with default values #16597
Comments
@john-altitude Is this only in v26.1, or is this error present in prior releases well? @anandolee Jie, can you take a look and let me know if this needs a fix / patch? |
I'm not certain about prior releases, but this error was NOT present with libprotoc 3.6.1 and protobuf package 3.19.3. I only discovered this when updating last week but I haven't investigated other prior releases. |
Its likely this is due to the change in default python implementation to Python UPB in v21.x. Can you verify if you still hit this error using the Python C++ implementation by setting PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp per https://protobuf.dev/reference/python/python-generated/#sharing-messages? We should have handling for duplicate adds of the same file in descriptor_pool.c, but it looks like this is being treated as not a match in def_pool.c. |
Sorry but can you verify, I would enable this by building protobuf from source with the |
What version of protobuf and what language are you using?
Version: libprotoc 26.1, protobuf==5.26.1
Language: Python
Operating System: Ubuntu 20.04.6
Python version 3.8
What did you do?
What did you expect to see
No error should happen, protobuf should recognize that the file being imported and serialized is already in the descriptor pool and should continue without error.
What did you see instead?
The following error message occurs when the AddSerializedFile function is run in the _pb2 file:
I've attached a .proto and the corresponding _pb2.py file and python script to reproduce this bug. If the default value for
Sample.a
is set to 1.1, for example, the script will fail, while setting it to 1 causes no errors.This bug is especially difficult to deal with because I am running an application through streamlit, which causes re-imports to trigger frequently.
.proto file
class_a_pb2.py
Example Script
The text was updated successfully, but these errors were encountered: