Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4226

Type Safety (Structs) not satisfied in Python and Node.js

    XMLWordPrintableJSON

    Details

    • Flags:
      Patch, Important

      Description

      Python and Node.js client and server generated code doesn't make a validation on the type of Struct passed as argument of a Service.
      Example:

          // First Struct
          struct StructA {
               1: required string query,
               2: required i32 max_results
          }
          // Second Struct
          struct StructB {
               1: required string query
          }
          // Service with a method that has the second Struct as argument
          service Question {
               string make_question(1: StructB);
          }
      

      After generating the python and Node.js code from this thrift file, the behaviour occurs when the client calls the server method passing a different Struct type to it (example with python client):

          res = client.make_question(StructA(query="hello", max_results=5))
      

      This code doesn't throw any kind of error, because the type of the Struct is not validated and the two Structs from the example have the same argument 'query'.
      Neither the server side throws an exception, interpreting the upcoming client message as StructB, even if its type is StructA.
      Is it possible that this kind of check is not made in any of the non-typed languages supported by thrift?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              matteotosi Matteo Tosi
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: