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

merging protos with Any fields generates a fictional, invalid proto field #113

Open
vchudnov-g opened this issue Feb 3, 2024 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@vchudnov-g
Copy link
Collaborator

So far I've only seen this in generated proto messages that have a field of type protobuf.Any. If one merges such a proto file with another one, a new fictional field is created in the message containing the Any. The fictional field is is listed inside the .proto file as null google = XXX, where XXX is a field number. What's even stranger is that this happens even if the "previous" .proto being merged with came from the exact same source as the current proto being generated.

Reproduction steps:

  1. Disable the check in copyField() introduced in fix(merge): disable merging proto fields when both old and new versions have type==null #112:
     if (valueType == null && keyType == null) {      
       // return null;    <-- disable this line
    
  2. Generate the proto file /tmp/compute.examine.0.proto without merging with any previous proto (no --previous_proto_file_path):
    java -jar target/disco-to-proto3-converter-0.0.1-SNAPSHOT-jar-with-dependencies.jar "--discovery_doc_path=${DIREGAPIC_GOOGLEAPIS}/google/cloud/compute/v1/compute.v1.json" '--service_ignorelist=HttpHealthChecks,HttpsHealthChecks' '--message_ignorelist=HttpHealthCheck,HttpsHealthCheck,HttpHealthCheckList,HttpsHealthCheckList,GetHttpHealthCheckRequest,GetHttpsHealthCheckRequest,PatchHttpHealthCheckRequest,PatchHttpsHealthCheckRequest,UpdateHttpHealthCheckRequest,UpdateHttpsHealthCheckRequest,InsertHttpHealthCheckRequest,InsertHttpsHealthCheckRequest,ListHttpHealthChecksRequest,ListHttpsHealthChecksRequest,DeleteHttpHealthCheckRequest,DeleteHttpsHealthCheckRequest' '--enums_as_strings=True' '--output_file_path=/tmp/compute.examine.0.proto'
    
  3. Generate the proto file /tmp/compute.examine.1.proto from the same source, but merging with the previous /tmp/compute.examine.0.proto (with the --previous_proto_file_path):
    java -jar target/disco-to-proto3-converter-0.0.1-SNAPSHOT-jar-with-dependencies.jar "--discovery_doc_path=${DIREGAPIC_GOOGLEAPIS}/google/cloud/compute/v1/compute.v1.json" "--previous_proto_file_path=/tmp/compute.examine.0.proto" '--service_ignorelist=HttpHealthChecks,HttpsHealthChecks' '--message_ignorelist=HttpHealthCheck,HttpsHealthCheck,HttpHealthCheckList,HttpsHealthCheckList,GetHttpHealthCheckRequest,GetHttpsHealthCheckRequest,PatchHttpHealthCheckRequest,PatchHttpsHealthCheckRequest,UpdateHttpHealthCheckRequest,UpdateHttpsHealthCheckRequest,InsertHttpHealthCheckRequest,InsertHttpsHealthCheckRequest,ListHttpHealthChecksRequest,ListHttpsHealthChecksRequest,DeleteHttpHealthCheckRequest,DeleteHttpsHealthCheckRequest' '--enums_as_strings=True' '--output_file_path=/tmp/compute.examine.1.proto'
    
  4. Diff /tmp/compute.examine.0.proto and /tmp/compute.examine.0.proto
@vchudnov-g vchudnov-g added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Feb 3, 2024
@vchudnov-g
Copy link
Collaborator Author

This is related, or possibly the same issue, as #114.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant