[
https://issues.apache.org/jira/browse/THRIFT-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Matteo Tosi updated THRIFT-4226:
--------------------------------
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:
{code:java}
// 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);
}
{code}
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):
\\
{code:java}
res = client.make_question(StructA(query="hello", max_results=5))
{code}
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?
was:
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:
{code:java}
// 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);
}
{code}
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):
\\
{code:java}
res = client.make_question(StructA(query="hello", max_results=5))
{code}
This code doesn't not 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?
> Type Safety (Structs) not satisfied in Python and Node.js
> ---------------------------------------------------------
>
> Key: THRIFT-4226
> URL: https://issues.apache.org/jira/browse/THRIFT-4226
> Project: Thrift
> Issue Type: Bug
> Components: Node.js - Library, Python - Library
> Affects Versions: 0.10.0
> Environment: macOs: 10.11.6
> Thrift: 0.10.0
> Python: 3.6
> Node.js: 8.0.0
> Reporter: Matteo Tosi
> Labels: node.js, patch, python, struct, structtype
> Fix For: 0.10.0
>
>
> 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:
> {code:java}
> // 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);
> }
> {code}
> 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):
> \\
> {code:java}
> res = client.make_question(StructA(query="hello", max_results=5))
> {code}
> 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?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)