From dev-return-55760-archive-asf-public=cust-asf.ponee.io@thrift.apache.org Mon Mar 11 11:01:05 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id DA31A180657 for ; Mon, 11 Mar 2019 12:01:04 +0100 (CET) Received: (qmail 88363 invoked by uid 500); 11 Mar 2019 11:01:03 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 88352 invoked by uid 99); 11 Mar 2019 11:01:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Mar 2019 11:01:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 79A20C5AAF for ; Mon, 11 Mar 2019 11:01:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id p73leazv528q for ; Mon, 11 Mar 2019 11:01:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 4A93F60F6D for ; Mon, 11 Mar 2019 11:01:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 54D59E0C57 for ; Mon, 11 Mar 2019 11:01:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 0D36B257FF for ; Mon, 11 Mar 2019 11:01:00 +0000 (UTC) Date: Mon, 11 Mar 2019 11:01:00 +0000 (UTC) From: "Jack Flecher (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (THRIFT-4815) Golang thrift and Python don't write the same messages MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/THRIFT-4815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16789408#comment-16789408 ] Jack Flecher commented on THRIFT-4815: -------------------------------------- Also I have to admit I have little to no knowledge about the server implementation in question but I did some manual testing with my own http requests and sending this POST body just works: b'\x82!\x01\x0bsendMessage\x15\x00\x1c(!u218891b1a7af4d21ffe4918acbeb9a73\x88\x04test\x00\x00' As you can see the only thing I changed was the order of fields not anything else, the \x01 that python seems to replace with \x00 (in this part of the body "\x82!\x01\x0bsendMessage") is still the same as Golang's thrift implementation writes it. > Golang thrift and Python don't write the same messages > ------------------------------------------------------ > > Key: THRIFT-4815 > URL: https://issues.apache.org/jira/browse/THRIFT-4815 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler, Go - Library, Python - Compiler, Python - Library > Affects Versions: 0.11.0, 0.12.0 > Environment: Python: > Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32 > Thrift version 0.11.0 tested. > Golang: > Thrift versions 0.12.0 and 0.11.0 tested > go version go1.11.4 windows/amd64 > go env: > set GOARCH=amd64 > set GOBIN= > set GOCACHE=C:\Users\BUNNY\AppData\Local\go-build > set GOEXE=.exe > set GOFLAGS= > set GOHOSTARCH=amd64 > set GOHOSTOS=windows > set GOOS=windows > set GOPATH=C:\Users\BUNNY\go > set GOPROXY= > set GORACE= > set GOROOT=C:\Go > set GOTMPDIR= > set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 > set GCCGO=gccgo > set CC=gcc > set CXX=g++ > set CGO_ENABLED=1 > set GOMOD= > set CGO_CFLAGS=-g -O2 > set CGO_CPPFLAGS= > set CGO_CXXFLAGS=-g -O2 > set CGO_FFLAGS=-g -O2 > set CGO_LDFLAGS=-g -O2 > set PKG_CONFIG=pkg-config > set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\BUNNY\AppData\Local\Temp\go-build552047466=/tmp/go-build -gno-record-gcc-switches > Reporter: Jack Flecher > Priority: Blocker > Labels: newbie > Attachments: bunny.thrift > > > I'm trying to port a tool that relies on Thrift from Python to Golang, it is a client not a server. > The thrift protocol behaves inconsistent when comparing Python and Golang and it results in breaking applications. > What it boils down to is I have a struct called Message with a certain amount of fields and I have a sendMessage method that takes that message and sends it to a server which then processes that. > In Python I can simply make a Message object, set some user's userId as receiver and the text after which I can send the message using sendMessage() > In Golang I can do the exact same but I run into error responses from the server saying another field that isn't required cannot be found. > In Python this is the generated POST body sent to the server: > b'\x82!\x00\x0bsendMessage\x15\x00\x1c(!u218891b1a7af4d21ffe4918acbeb9a73\x88\x04test\x00\x00' > b'\x82!\x00\x0bsendMessage\x15\x00\x1c(!u218891b1a7af4d21ffe4918acbeb9a73\x88\x05test2\x00\x00' > In Golang the generated POST body sent to the server: > b'\x82!\x01\x0bsendMessage\x15\x00\x1c(\x04test\x88!u218891b1a7af4d21ffe4918acbeb9a73\x00\x00' > b'\x82!\x02\x0bsendMessage\x15\x00\x1c(\x05test2\x88!u218891b1a7af4d21ffe4918acbeb9a73\x00\x00' > As demonstrated above therre are two differences in the generated POST bodies but the one causing the error is the fact that the fields are in a different order than they are supposed to. > In Golang trying to reverse the order of the fields causes this POST body to be generated: > b'\x82!\x01\x0bsendMessage\x15\x00\x1c\xa8!u218891b1a7af4d21ffe4918acbeb9a73\x08\x04\x04test\x00\x00' > When commenting out all the fields I actually don't want to be written and then only reversing the functions that are actually writing data, the ones for the receiver and text fields the POST body looks like this: > b'\x82!\x01\x0bsendMessage\x15\x00\x1c(\x04test\x88!u218891b1a7af4d21ffe4918acbeb9a73\x00\x00' > To summarize, the Thrift protocol on Golang is broken in certain cases because fields are not written in the right order causing other implementatings of Thrift to stop serving Golang Thrift clients. -- This message was sent by Atlassian JIRA (v7.6.3#76005)