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

Ignore empty codegen modules in outputs #726

Conversation

trevoranderson
Copy link
Contributor

References:
Original report: #228
My report: #724
Partial fix in: #605
Issue with fix: hyperium/tonic#964
Reverted in: #639

After digging in, the issue with the first fix is that while it prevented the file from being generated, it did not prevent the file from being referenced in the "include" file because both locations iterate the module hash. My proposed solution is to instead avoid adding the empty module to the list at all. Then the file does not get output and the include file does not have an entry that would otherwise be referencing an empty file.

Also did a small refactor pass on the surrounding loop to destructure the tuple instead of using tuple.0 syntax wherever it is used.

Tested by reproducing the original issue using tonic-build with the original behavior working then reintroduced the bug, then fixed it with my changes. Manually verified output files and included them in a new rust project to make sure they worked and verified that the extra file is not present in file system or the include file. Also ran cargo test on prost

@LucioFranco
Copy link
Member

@trevoranderson thank you for doing this! Would it be possible to add a test of the original behavior that was fixed with this so we can make sure we don't regress in the future?

…x and seeing it fail, by adding the non-working reverted fix and seeing it still fail, and finally by adding the fix back in and seeing it pass
@trevoranderson
Copy link
Contributor Author

Made an attempt at that too. I used an proto adapted from the hyperium issue report which reproduces the issue without my fix and works with the fix applied.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@@ -156,6 +150,13 @@ use crate::ident::to_snake;
use crate::message_graph::MessageGraph;
use crate::path::PathMap;

mod ast;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

@LucioFranco LucioFranco merged commit ec385dc into tokio-rs:master Oct 17, 2022
@matze matze mentioned this pull request Nov 7, 2022
tottoto added a commit to tottoto/tonic that referenced this pull request Jan 17, 2023
This file was generated by the previous version of prost-build.
This behaviour was fixed in tokio-rs/prost#726.
tottoto added a commit to tottoto/tonic that referenced this pull request Jan 17, 2023
This file was generated by the previous version of prost-build.
This behaviour was fixed in tokio-rs/prost#726.
LucioFranco pushed a commit to hyperium/tonic that referenced this pull request Feb 4, 2023
This file was generated by the previous version of prost-build.
This behaviour was fixed in tokio-rs/prost#726.
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

Successfully merging this pull request may close these issues.

After updating to v0.7 with prost-types v0.10 "google.protobuf.rs" is not available
2 participants