cloudwego / hertz

Go HTTP framework with high-performance and strong-extensibility for building micro-services.
https://www.cloudwego.io
Apache License 2.0
5.28k stars 515 forks source link

请求字段带有 form tag 的时候, query 会覆盖 json body 字段 #1218

Open LomotHo opened 1 day ago

LomotHo commented 1 day ago

Describe the bug

我的idl是这样的:

struct RegisterReq {
...
    4: string psm (api.body="psm",api.vd="(len($) > 0)")
...
}

生成的结构体是这样的

type RegisterReq struct {
...
    Psm         string  `thrift:"psm,4" form:"psm" json:"psm" vd:"(len($) > 0)"`
...
}

这里有两个问题

  1. 为这个字段生成 form:"psm" tag 是否符合预期
  2. 我在执行请求时在query中填了 ?psm=aaa , 同时body中有 "psm":"bbb", 我得到的RegisterReq中的psm是bbb, 即出现了query覆盖body的情况

Hertz version: v0.9.3

Environment:

go env GO111MODULE='on' GOARCH='arm64' GOBIN='' GOCACHE='/Users/lomot/Library/Caches/go-build' GOENV='/Users/lomot/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/lomot/go/pkg/mod' GONOPROXY='.gitlab.com,.gitee.com,gitlab.xaminim.com' GONOSUMDB='.gitlab.com,.gitee.com,gitlab.xaminim.com' GOOS='darwin' GOPATH='/Users/lomot/go' GOPRIVATE='.gitlab.com,.gitee.com,gitlab.xaminim.com' GOPROXY='https://goproxy.cn,direct' GOROOT='/opt/homebrew/Cellar/go@1.22/1.22.8/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='local' GOTOOLDIR='/opt/homebrew/Cellar/go@1.22/1.22.8/libexec/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.22.8' GCCGO='gccgo' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/Users/lomot/Code/mm/service-framework/bedrockapp-meta/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/q0/16fcs20j107d47rm0qyjw7880000gp/T/go-build3305570707=/tmp/go-build -gno-record-gcc-switches -fno-common'