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

After upgrading go-zero from 1.7.3 to 1.7.4, httpx.Parse throws an error. How can this be fixed? #4578

Closed
mowocc opened this issue Jan 17, 2025 · 6 comments · Fixed by #4542

Comments

@mowocc
Copy link

mowocc commented Jan 17, 2025

go-zero 从1.7.3 升级到1.7.4 后 httpx.Parse 报错,当http请求参数中有空值时解析错误。

报错如下:

strconv.ParseInt: parsing "": invalid syntax

参数结构体如下:

type RequestPagination struct {
	Page     int `form:"page,optional"`
	PageSize int `form:"page_size,optional"`
}

请问是什么原因呢?或者做什么修改呢?

@mowocc mowocc changed the title go-zero 从1.7.3 升级到1.7.4 后 httpx.Parse 报错 go-zero 从1.7.3 升级到1.7.4 后 httpx.Parse 报错,请问怎样修复? Jan 17, 2025
@mowocc
Copy link
Author

mowocc commented Jan 17, 2025

当我尝试更新到最新的1.7.6版本,还是有同样的错误,请问这是什么原因引起的?应该怎样修复?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


When I try to update to the latest 1.7.6 version, I still get the same error. What is the cause of this? How should it be fixed?

@mowocc
Copy link
Author

mowocc commented Jan 17, 2025

  1. 已经找原因,为了支持浏览器get数组参数,自定义了JSON.stringify(array)处理get数组参数。
  2. 因为1.7.4升级了数组参数解析方式,导致该写法无法被解析,只需要删除该处理就可以正常使用。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


  1. The reason has been found. In order to support the browser's get array parameters, JSON.stringify(array) has been customized to handle the get array parameters.
  2. Because 1.7.4 has upgraded the array parameter parsing method, this writing method cannot be parsed. You only need to delete this processing to use it normally.

@mowocc
Copy link
Author

mowocc commented Jan 17, 2025

升级1.7.4版本后,optional可选参数修饰符不生效,导致所有数字类型的字段,在传递空值时报错。

比如以下结构体:

type UserInfoRequest struct {
	UserId  int32 `form:"user_id,optional"`
}

当请求参数传递了user_id 字段,但该字段值为空,会触发以下报错:

strconv.ParseInt: parsing "": invalid syntax

请官方查看一下该问题

@kevwan kevwan changed the title go-zero 从1.7.3 升级到1.7.4 后 httpx.Parse 报错,请问怎样修复? After upgrading go-zero from 1.7.3 to 1.7.4, httpx.Parse throws an error. How can this be fixed? Jan 17, 2025
@kevwan kevwan linked a pull request Jan 17, 2025 that will close this issue
@kevwan
Copy link
Contributor

kevwan commented Jan 17, 2025

fixed in #4542

@kevwan kevwan closed this as completed Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants