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

Added large ints test case #611

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Added large ints test case #611

merged 1 commit into from
Sep 27, 2024

Conversation

nesitor
Copy link
Member

@nesitor nesitor commented Sep 26, 2024

Fix: Add a test for large ints to ensure don't raises a TypeError

Self proofreading checklist

  • Is my code clear enough and well documented
  • Are my files well typed
  • Are there enough tests

Changes

Added a test case ensuring that large ints doesn't break the json load and dump

How to test

Execute the test suite

@nesitor nesitor requested a review from hoh September 26, 2024 09:55
@nesitor nesitor self-assigned this Sep 26, 2024
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.38%. Comparing base (7334301) to head (b5fcbbf).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #611   +/-   ##
=======================================
  Coverage   94.37%   94.38%           
=======================================
  Files          91       91           
  Lines        4910     4916    +6     
  Branches      677      677           
=======================================
+ Hits         4634     4640    +6     
  Misses        241      241           
  Partials       35       35           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

hoh
hoh previously approved these changes Sep 27, 2024
@hoh hoh dismissed their stale review September 27, 2024 10:53

Forgot about JS

@hoh
Copy link
Member

hoh commented Sep 27, 2024

What strategy should be used to avoid breaking Javascript and non-Python clients ?

Javascript integers are limited to about 2^53

There are already have a few messages stored in the database with too large integers, and loading these from JSON in any language other than Python would result in a client crash if these are served.

Would it make more sense to handle this problem on the server side and not serve these messages ?
(as well as not accepting new ones)

@nesitor nesitor merged commit 0331343 into main Sep 27, 2024
6 checks passed
@nesitor nesitor deleted the andres-fix-add_large_ints_test branch September 27, 2024 14:07
@nesitor
Copy link
Member Author

nesitor commented Sep 27, 2024

What strategy should be used to avoid breaking Javascript and non-Python clients ?

Javascript integers are limited to about 2^53

There are already have a few messages stored in the database with too large integers, and loading these from JSON in any language other than Python would result in a client crash if these are served.

Would it make more sense to handle this problem on the server side and not serve these messages ? (as well as not accepting new ones)

At the moment Javascript don't crash handling this messages with large ints, the unique thing that does is loose precision (see https://stackoverflow.com/questions/34561827/how-do-i-deal-with-number-greater-than-253-in-javascript#:~:text=The%20%C2%B1253%20range,use%20a%20Javascript%20bignum%20library.). And the unique clients that we have for the API is JavaScript and Python.
I think that the API should not assume the task to check if the ints are so large or not, only if it can handle it and store it and not crash. The responsability about what is saved and what is loaded is from the user that saves the message, so if the API can manage, save and serve it without crash it is fine.

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

Successfully merging this pull request may close these issues.

2 participants