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

net/ghttp: Param in header would affect the following params parse #4227

Open
UncleChair opened this issue Mar 28, 2025 · 1 comment
Open
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@UncleChair
Copy link
Contributor

Go version

go version go1.23.2 windows/amd64

GoFrame version

2.9.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

Initial web project with the latest version and modify the HelloReq to :

type HelloReq struct {
  g.Meta  `path:"/hello" tags:"Project" method:"get" sum:"List all projects"`
  Token   string `json:"Authorization" des:"JWT" in:"header"`
  Owned   bool   `json:"owned" in:"query" default:"false"`
  Deleted bool   `json:"deleted" in:"query" default:"false"`
}

Send the request and dump req in controller

curl --location 'http://localhost:8000/hello?deleted=false' \
--header 'Authorization: 1'

What did you see happen?

The dump info would show:

{
    Token:   "1",
    Owned:   true,
    Deleted: false,
}

What did you expect to see?

In the previous version (2.8.3), it was:

{
    Token:   "1",
    Owned:   false,
    Deleted: false,
}

Or if you move the Token to the end of the structure, it would also have the right dump:

{
    Owned:   false,
    Deleted: false,
    Token:   "1",
}

Seems some changes was made with the param parse? Haven't locate the bug yet, may be gconv related

@UncleChair UncleChair added the bug It is confirmed a bug, but don't worry, we'll handle it. label Mar 28, 2025
@UncleChair
Copy link
Contributor Author

for _, field := range fields {
if tagValue := field.TagIn(); tagValue != "" {
findKey := field.TagPriorityName()
switch tagValue {
case goai.ParameterInHeader:
foundKey, foundValue = gutil.MapPossibleItemByKey(headerMap, findKey)
case goai.ParameterInCookie:
foundKey, foundValue = gutil.MapPossibleItemByKey(cookieMap, findKey)
}
if foundKey != "" {
mergeTagValueWithFoundKey(data, true, foundKey, field.Name(), foundValue)
}
}
}

@gqcn Missing in query check here, seems related to #4182 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

1 participant