thriftpy2 icon indicating copy to clipboard operation
thriftpy2 copied to clipboard

How to decode some data without IDL files that encoding by Apache thrift TBinaryProtocol?

Open xf97 opened this issue 1 year ago • 3 comments

Hello colleagues from Eleme, this is Jia Mao from Ant Group. I have a question about how to use this library and would like to consult with you. I currently have some data that is encoded using Apache Thrift TBinaryProtocol, but I don't have the corresponding IDL files. However, from what I understand, Apache Thrift TBinaryProtocol is a self-describing protocol, so I should still be able to decode this data. I found some files in the code such as /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thriftpy2/protocol/binary.py and thriftpy2/protocol/binary.py, and methods such as read_struct, read_message_begin, and read_message_end seem to be able to help me solve the problem, but I don't know how to use them. Could you please help me with this issue? Thank you very much!

xf97 avatar Feb 28 '23 10:02 xf97

In my understanding, there should be a one-click decoding interface, such as raw_data = thriftpy.TBinaryProtocol().decode(bytes_data), because similar functionality should also be used in this lib. Even if it does not exist, this functionality can be easily composed through several sub-interfaces. However, I have not found detailed documentation to explain this problem.

xf97 avatar Feb 28 '23 10:02 xf97

According to the layout format definition of Apache Thrift, it could be possible that decode message without IDL. However, it is not the objective of thriftpy, so we have no intention of this.

ethe avatar Mar 01 '23 03:03 ethe

As a recommendation, you can use wiresharek to capture the thrift request and got the structured response, and use this to got the IDL.

aisk avatar Mar 02 '23 09:03 aisk