Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LomotHo opened this issue Oct 25, 2024 · 1 comment
Open

Comments

@LomotHo
Copy link

LomotHo commented Oct 25, 2024

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/[email protected]/1.22.8/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/[email protected]/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'

@xiaost
Copy link
Contributor

xiaost commented Oct 30, 2024

Appreciate that if you can share your solution here.
Be mindful that we should be cautious not to introduce any breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants