Team_RPCtester created THRIFT-5803: -------------------------------------- Summary: Inconsistencies in Handling Default Values for Required Fields Across Thrift Implementations Key: THRIFT-5803 URL: https://issues.apache.org/jira/browse/THRIFT-5803 Project: Thrift Issue Type: Bug Affects Versions: 0.20.0, 0.19.0 Reporter: Team_RPCtester
Hi, We discover an inconsistent behavior with respect to default values for required string fields. Specifically, in Go, a required string field is automatically initialized to an empty string if not explicitly set, whereas other languages do not automatically initialize this field. This inconsistency can be illustrated with the following example: Thrift Definition: {code:java} namespace go commonResource struct StructClass_0 { 1: required string f_1, } service DataService { StructClass_0 Method_1(1: StructClass_0 agr_method_1) } {code} Go client side, {code:java} agr_method_1_0 := commonResource.NewStructClass_0() fmt.Println(agr_method_1_0) // method_1_re_agr_method_1_0: StructClass_0({F_1:}) {code} python client side {code:java} agr_method_1 = StructClass_0() print(agr_method_1) # StructClass_0(f_1=None) {code} nodejs client side {code:java} arg_Method_1 = new ttypes.StructClass_0(); console.log(arg_Method_1); // { f_1: null } {code} GO server side {code:java} func (d DataServiceHandler) Method_1(ctx context.Context, agr_method_1 *commonResource.StructClass_0) (re_agr_method_1 *commonResource.StructClass_0, _err error) { re_agr_method_1 = agr_method_1 return re_agr_method_1, nil } {code} *Behavior Observed:* * On the Go client side, if agr_method_1_0 is sent with an uninitialized f_1, Go automatically sets f_1 to an empty string. The server receives this empty string and processes it accordingly. * On the Node.js client side, if arg_Method_1 is sent with an uninitialized f_1, Node.js client reports an error: "Required field f_1 is unset!" and does not allow the call to proceed. * On the Python client side, if agr_method_1 is sent with f_1 as null, the Go server reports: "*commonResource.StructClass_0 error reading struct: Required field F_1 is not, the Nodejs server will prompt “"Required field f_1 is unset!"”, the Python server will return what it receives. -- This message was sent by Atlassian Jira (v8.20.10#820010)