descriptor: reject missing reserved range bounds - #418
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
[claude code] Thanks for this one — the transactional tests and the borrow-only helper are good, but the presence check itself rejects descriptors that protoc and protobuf-go both accept, so it needs a different rule before it can go in. Neither reference tests whether a bound is set; both read the proto2 default of 0. For enums, That also points at the real gap, which the fragment claims but the diff does not cover: Suggested rework, which stays small:
Ordering note for the eventual merge: #421 inserts at the same line in One forward note since you're working through protoc's validation list: protobuf-go rejects |
# Conflicts: # buffa-descriptor/src/pool.rs
…, not presence protoc and protobuf-go read an unset reserved-range bound as 0 and never test presence: a message range must satisfy 0 < start < end, an enum range (inclusive, possibly negative) start <= end. The presence check rejected enum ranges both accept (e.g. an unset start meaning 'reserved 0 to 8') while still letting zero, negative, empty and reversed message ranges through to be silently dropped. ReservedRanges::for_message/for_enum now validate as they index; the error splits into InvalidMessageReservedRange and InvalidEnumReservedRange (the two kinds have different end semantics) and prints plain bounds. Tests cover both directions. Merged main; the DescriptorPool::new/decode error summaries keep main's wording pending a single rewrite after this series.
|
[claude code] I've done the rework described above so this can ride 0.10.0 with its siblings (7dda356): |
What changed
PoolError::InvalidReservedRange.Tests
cargo test --workspacecargo clippy --workspace --all-targets -- -D warningscargo fmt --all -- --checktask lint-md