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

fix(success response handler): parse unsafe integers as strings #834

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

fbeaudoincoveo
Copy link
Contributor

@fbeaudoincoveo fbeaudoincoveo commented Jun 20, 2024

JavaScript will automatically round integers that are outside of its "safe" bounds, i.e., from -(2^53 - 1) to 2^53 - 1, inclusive (±9,007,199,254,740,991). This means we'll lose precision if we convert values beyond those boundaries to integers.

The suggested fix is to return out of bound integers as strings, such that no precision will be lost.

Technically, this means that any number in a successful response body will be typed as a number (if it's safe) or as as string (if it's unsafe).

I decided not to adjust the response body interfaces, because this should happen only in a few exceptional cases (e.g., rowid / sysrowid, which are returned as very large integers).

Acceptance Criteria

  • My changes are publicly available, documented, and deployed in production. (i.e. on Swagger)
  • JSDoc annotates each property added in the exported interfaces
  • The proposed changes are covered by unit tests
  • Commits containing breaking changes a properly identified as such
  • README.md is adjusted to reflect the proposed changes (if relevant)
  • My merge commit message will be conventional (See Conventional Commit)

@fbeaudoincoveo fbeaudoincoveo requested a review from a team June 20, 2024 13:51
@fbeaudoincoveo fbeaudoincoveo requested a review from a team as a code owner June 20, 2024 13:51
Copy link
Member

@toofff toofff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine by me, if the @coveo/dx team is okay with the change.

@fbeaudoincoveo fbeaudoincoveo added this pull request to the merge queue Jun 20, 2024
Merged via the queue into master with commit 4727150 Jun 20, 2024
5 checks passed
@fbeaudoincoveo fbeaudoincoveo deleted the KIT-3321 branch June 20, 2024 17:21
Copy link

🎉 This PR is included in version 54.9.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants