httpie / desktop

🚀 HTTPie Desktop — cross-platform API testing client for humans. Painlessly test REST, GraphQL, and HTTP APIs.
https://httpie.io
Other
2.85k stars 32 forks source link

[Bug]: wrong response (json int64) #163

Open gniqizeuy opened 5 months ago

gniqizeuy commented 5 months ago

What happened?

diff response about json int64 field

request

image

response

image

in chrome

image

diff id in list filed

id in db is same as response frome chrome not the httpie response

Steps to reproduce?

just send the GET http request

What did you expect to happen?

show correct int64 value

Platform

macOS

HTTPie Desktop version

2024.1.2

Relevant log output

No response

Code of Conduct

jkbrzt commented 5 months ago

Hi @gniqizeuy, thanks for the report. This is indeed a bug. We shouldn’t alter the displayed data. For what it’s worth, you can always use the “Raw” body view mode to see the response body as provided by the server:

image

Background: JSON doesn’t really support int64. We currently use JSON.stringify() under the hood to prettify the body, which means we parse the data, and JS alters the unsafe integer value.

Number.isSafeInteger(68164106661659011)  // → false

A simple test: add the following to the request body JSON editor and invoke “Prettify”:

{
  "foo": 68164106661659011
}

We need to prevent this alteration. Ideally, we’d also warn the user when unsafe integers appear in the request/response JSON.