slachiewicz opened a new pull request, #3822:
URL: https://github.com/apache/thrift/pull/3822

   Client: go
   
   ### Problem
   When serializing a Go struct that contains a nil union field with default 
requiredness, `t_go_generator` generated code that invoked `CountSetFields` on 
the nil union receiver, causing a runtime panic (`invalid memory address or nil 
pointer dereference`).
   
   ### Changes
   1. Added a nil check to `CountSetFields` in 
`compiler/cpp/src/thrift/generate/t_go_generator.cc` returning 0 when the union 
receiver is `nil`.
   2. Added an `IsSet<Field>` check in `writeField` for default-requiredness 
pointer fields, skipping unset (nil) pointers during serialization. This 
matches the behavior of Python, Java, Rust, Node.js, and C# per the Thrift IDL 
specification (`doc/specs/idl.md:131`).
   3. Added unit regression tests in 
`lib/go/test/tests/union_default_value_test.go` and 
`lib/go/test/UnionDefaultValueTest.thrift`.
   
   Co-Authored-By: Antigravity 2.0 <[email protected]>


-- 
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