Adam Hawkins created THRIFT-3015: ------------------------------------ Summary: Ruby structs are not recursively validated Key: THRIFT-3015 URL: https://issues.apache.org/jira/browse/THRIFT-3015 Project: Thrift Issue Type: Bug Components: Ruby - Compiler Affects Versions: 0.9.2 Environment: Ruby client & Ruby Server Reporter: Adam Hawkins Priority: Minor
I've come across something that I had fixed in a third party library, but after working with generated & ruby thrift library code I decided to file an issue here. The root cause is that {{Thrift::Struct}} & {{Thrift::Struct_Union}} sub-classes do not call {{validate}} on struct members of the same type. This is problematic because the library does correctly call {{validate}} to prevent the server or client from sending mal-formated message. Unfortunately this only works for simple protocols that don't use structs. This creates a bad user experience. Take this example protocol. {code} struct EchoMessage { 1: required string message } struct NestedEchoMessage { 1: required EchoMessage echo } service EchoService { NestedEcho echo(1: string message) } {code} And a simple & incorrect implementation in ruby: {code} class Handler def echo(message) # note the nested Echo struct is missing NestedEcho.new end end {code} This code has a few problems, but the key issue is that thrift library will attempt to send this message over the write & the client incorrectly receive a {{Thrift::Transport}} exception when it should receive a {{Thrift::ProtocolException}}. -- This message was sent by Atlassian JIRA (v6.3.4#6332)