fix: handle synthetic oneofs for proto3 optional fields#26
fix: handle synthetic oneofs for proto3 optional fields#26dsociative wants to merge 4 commits intolinka-cloud:mainfrom
Conversation
8e076ab to
f6004cd
Compare
Add `containing_non_synthetic_oneof` helper to distinguish between real oneofs and synthetic oneofs generated for proto3 optional fields. This fixes incorrect path generation where optional fields were being treated as regular oneof members (e.g., `message._field.field` instead of `message.field`).
f6004cd to
3b2041c
Compare
|
Thanks a lot for this contribution @dsociative! When you get a chance, could you please rebase the PR on the latest main branch? |
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
f5d32aa to
6f977d3
Compare
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
6f977d3 to
dd25e1c
Compare
|
Thanks for the review! I've rebased on the latest main. I've encountered an edge case with this test that's now failing due to the fix. The proto defines an message MessageRequiredButOptional { optional TestMsg val = 1 [(validate.rules).message.required = true]; }With Rust's type system, we can't distinguish between an unset optional field and one explicitly set to |
|
Thanks @dsociative ! Can you please run I’ll check the failing test. |
|
Thanks @dsociative ! |
Fix path generation for proto3 optional fields
Problem
Proto3
optionalfields are implemented using synthetic oneofs (e.g.,oneof _field { string field = 1; }).prost-validatewas treating these as regular oneofs, generating incorrect paths likemessage._field.fieldinstead ofmessage.field.Solution
Added
containing_non_synthetic_oneof()helper that filters out synthetic oneofs usingis_synthetic()check, ensuring correct path generation for optional fields.Updated
prost-reflectto the latest version and all its dependencies, as theis_synthetic()method onOneofDescriptorwas only added in recent versions.Changes
message.fieldmessage.oneof_name.fieldmessage.fieldprost-reflectand dependencies to supportis_synthetic()API