thriftgo icon indicating copy to clipboard operation
thriftgo copied to clipboard

Processor method `exception` field is not optional.

Open ii64 opened this issue 3 years ago • 0 comments

Describe the bug

Service method exception field is not optional, so that will always be written to the wire. This resulting a misbehaviour for clients thinking that there's an error/exception. I am not using Kitex, but this should be reproducible with it. I was looking for Kitex example but it seem there's no case for it (referring to bizdemo/easy_note/idl/note.thrift and search "throws").

To Reproduce

Steps to reproduce the behavior:

  1. Default generate config, with unknown field enabled (thriftgo).
  2. Apache Thrift generate code for NodeJS (js:"node,ts,es6").

Expected behavior

Works well with method exceptions. make exception field optional.

Screenshots

Server (thriftgo)
type CoreServiceGetClassroomsResult struct {
	Success        *structs.GetClassRoomsResponse `thrift:"success,0,optional" frugal:"0,optional,structs.GetClassRoomsResponse" db:"success" json:"success,omitempty"`
	E              *exceptionsc.CommonException   `thrift:"e,1" frugal:"1,default,exceptionsc.CommonException" db:"e" json:"e"`
	_unknownFields unknown.Fields
}

image

Client (thrift/NodeJS)

image

Kitex version:

Direct use of thriftgo.

Environment:

go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Nugraha\AppData\Local\go-build
set GOENV=C:\Users\Nugraha\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Nugraha\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Nugraha\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\Nugraha\AppData\Local\Temp\go-build439957652=/tmp/go-build -gno-record-gcc-switches

Additional context

tbd.

ii64 avatar Aug 10 '22 11:08 ii64