go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

httpx.parse error when the field's type in request is []byte

Open giantcroc opened this issue 2 months ago • 5 comments

Describe the bug httpx.parse error when the field's type in request is []byte and I post the data body after json Marshal like '{"task":"base64 encoded data"}'.

To Reproduce Steps to reproduce the behavior, if applicable:

  1. The code is
  ApplyRequest {
  Task []byte `json:"task"`
  }
  ApplyResponse {
  ApplyResult string `json:"applyresult"`
  }
  1. The error is

    error: fullName: `task`, error: `string: `dGFza25hbWU6IHRhc2sxCmpvYmxpc3Q6Ci0gam9ibmFtZTogYnVpbGQKICBqb2J1cmw6IGh0dHA6Ly9qZW5raW5zLmV4YW1wbGUuY29tL2pvYi9CdWlsZFByb2plY3RBCiAgcGFyYW1ldGVyczoKICAgIG5vZGVsYWJlbDogbGludXgKICAgIGFyY2hpdGVjdHVyZTogeDg2XzY0CiAgICBwcm9kdWN0dHlwZTogYXBwbGljYXRpb24KICAgIHB5dGhvbnZlcnNpb246ICIzLjgiCiAgamVua2luc25hbWU6IGplbmtpbnNfbWFpbgogIHByaW9yaXR5OiAxCi0gam9ibmFtZTogdGVzdCBwcm9qZWN0IGIKICBqb2J1cmw6IGh0dHA6Ly9qZW5raW5zLmV4YW1wbGUuY29tL2pvYi9UZXN0UHJvamVjdEIKICBwYXJhbWV0ZXJzOgogICAgbm9kZWxhYmVsOiB3aW5kb3dzCiAgICBhcmNoaXRlY3R1cmU6IHg4Nl82NAogICAgcHJvZHVjdHR5cGU6IGxpYnJhcnkKICAgIHB5dGhvbnZlcnNpb246ICIzLjkiCiAgamVua2luc25hbWU6IGplbmtpbnNfdGVzdAogIHByaW9yaXR5OiAy`, error: `invalid character 'd' looking for beginning of value``
    

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environments (please complete the following information):

  • OS: [e.g. Linux]
  • go-zero version 1.6.5
  • goctl version goctl version 1.6.6 linux/amd64

More description Add any other context about the problem here.

giantcroc avatar Jun 26 '24 10:06 giantcroc