Request Body containing a number close to Number.MAX_SAFE_INTEGER
has the number transformed to a string
#2870
Closed
2 tasks done
Labels
bug
Something isn't working
I have checked the following:
Describe the bug
Creating a request with a body like this:
Sends this request:
Note the quotes around the number on the last line.
I consider this a bug. It is not documented behavior, and causes non-obvious errors. The api I was testing reported an invalid request error, and it took me hours to find out that Bruno was the culprit, because it changed the datatype of the number to string.
I investigated why this is happening (theory):
here json-bigint is used to parse the request body and pass it to axios. However, axios does not correctly serialize it back to the same string as the input. I believe
JSONBig.stringify
must be used to ensure correct conversion.Alternatively, just giving axios the input string without ever parsing it might be an option.
Note: the
req.body
object in the script context already has the field as a string...bru file to reproduce the bug
Screenshots/Live demo link
n/a
The text was updated successfully, but these errors were encountered: