Jens-G commented on PR #3414:
URL: https://github.com/apache/thrift/pull/3414#issuecomment-4339451527

   ### Code review
   
   Found 2 issues:
   
   1. **`is_boxed_union` false-positive for typedef-aliased union fields** — 
The check `to_rust_type(tfield->get_type()) != resolved_type` uses 
`to_rust_type` on both sides, but `get_true_type()` only on the right. If a 
field's declared type is a typedef over a union (not a `Box<>`-wrapped union), 
`to_rust_type` on the typedef returns the alias name while `resolved_type` is 
the concrete union name — `is_boxed_union` becomes `true` incorrectly, and the 
generator emits `Box::new(val)` into a non-boxed field, producing a type error 
in all generated code for typedef-aliased union fields.
   
   
https://github.com/santiagomed/thrift/blob/c63c487ab438843ca6b7602105cd0a29ae1a7764/compiler/cpp/src/thrift/generate/t_rs_generator.cc#L1707-L1712
   
   2. **`EmptyUnion` conflates two distinct error cases** — The variant doc 
says "A Thrift union was deserialized with no recognized variants" 
(forward-compat scenario). But the same kind is also raised when 
`received_field_count == 0` — i.e., when the sender emitted a union with zero 
fields on the wire (a genuine protocol violation). The struct-level catch arm 
that swallows `EmptyUnion` for forward-compat will also silently suppress these 
genuine violations, converting hard errors into `None`.
   
   
https://github.com/santiagomed/thrift/blob/c63c487ab438843ca6b7602105cd0a29ae1a7764/compiler/cpp/src/thrift/generate/t_rs_generator.cc#L1854-L1858
   
   🤖 Generated with [Claude Code](https://claude.ai/code)
   
   <sub>- If this code review was useful, please react with 👍. Otherwise, react 
with 👎.</sub>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to