Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes prost-build more robust when given malformed FileDescriptorSet input by turning two previously panicking descriptor unwraps into proper io::Error returns (surfacing as ErrorKind::InvalidInput) and adding regression tests to lock in the behavior.
Changes:
- Made
MessageGraphconstruction fallible and replaced panic-prone unwraps with explicit error returns for missing message names and missing non-repeated message-fieldtype_name. - Propagated
MessageGraphconstruction failures throughConfig::generateasio::ErrorKind::InvalidInput. - Added unit tests ensuring
compile_fdsdoes not panic and returns the expected error kind/message for the two reported malformed descriptor shapes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| prost-build/src/message_graph.rs | Makes message graph building return Result and converts the two panic paths into explicit errors. |
| prost-build/src/config.rs | Maps MessageGraph failures to InvalidInput and adds regression tests for the two malformed-input cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MessageGraphconstruction fallible and validate required descriptor values before graph/code generationio::ErrorKind::InvalidInputwhen message or enum names are missing or emptyio::ErrorKind::InvalidInputwhenMessage,Group, orEnumfieldtype_namevalues are missing or empty, including repeated fieldsScope
This change intentionally validates only required message and enum names and required field
type_namevalues forMessage,Group, andEnumfields. Non-empty type names retain the existing behavior, and this does not add generalFileDescriptorSetvalidation.Testing
cargo fmt --all --checkcargo test -p prost-build(42 unit tests and 21 doctests passed; 7 doctests ignored)cargo test -p prost-build --no-default-features(42 unit tests and 21 doctests passed; 7 doctests ignored)cargo +1.95 test -p prost-build(42 unit tests and 21 doctests passed; 7 doctests ignored)cargo clippy -p prost-build --no-deps --all-features --tests --benches -- -D warnings -A clippy::useless_borrows_in_formattingThe workspace Clippy command on local Rust 1.97 reports a pre-existing
clippy::question_markwarning inprost-types/src/datetime.rs; CI pins Clippy 1.95.Closes #1415.