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

Request Body containing a number close to Number.MAX_SAFE_INTEGER has the number transformed to a string #2870

Closed
2 tasks done
vypxl opened this issue Aug 20, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@vypxl
Copy link

vypxl commented Aug 20, 2024

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

Creating a request with a body like this:

{
  "max": 9007199254740991
}

Sends this request:

> GET /x
> X-Tunnel-Auth-Token:
> x-tunnel-workflow: api
> content-type: application/json
> data {"max":"9007199254740980"}

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

meta {
  name: Bug
  type: http
  seq: 2
}

get {
  url: /bug
  body: json
  auth: none
}

body:json {
  {
    "max": 9007199254740991
  }
}

Screenshots/Live demo link

n/a

@vypxl vypxl added the bug Something isn't working label Aug 20, 2024
@jwetzell
Copy link
Contributor

This issue has been raised multiple times and seems to have a sort of "master" issue #2767 created by the team.

@vypxl
Copy link
Author

vypxl commented Aug 21, 2024

Closing in favor of #2767 , sorry for the spam.

@vypxl vypxl closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants