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

Problem: bigint in POST message makes GET messages.json return a 500 #476

Open
odesenfans opened this issue Sep 13, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@odesenfans
Copy link
Contributor

odesenfans commented Sep 13, 2023

A POST message was accepted containing a big integer. We should reject messages containing integers bigger than 2^53 (limit for valid JSON) as this breaks JSON serialization in the API.

[2023-09-13 10:14:26 +0000] [106] [ERROR] Error handling request
OverflowError: int too big to convert

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/sentry_sdk/integrations/aiohttp.py", line 126, in sentry_app_handle
    reraise(*_capture_exception(hub))
  File "/opt/venv/lib/python3.11/site-packages/sentry_sdk/_compat.py", line 60, in reraise
    raise value
  File "/opt/venv/lib/python3.11/site-packages/sentry_sdk/integrations/aiohttp.py", line 116, in sentry_app_handle
    response = await old_handle(self, request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pyaleph/src/aleph/web/controllers/messages.py", line 231, in view_messages_list
    return format_response(
           ^^^^^^^^^^^^^^^^
  File "/opt/pyaleph/src/aleph/web/controllers/messages.py", line 203, in format_response
    return web.json_response(text=aleph_json.dumps(response).decode("utf-8"))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pyaleph/src/aleph/toolkit/json.py", line 37, in dumps
    return orjson.dumps(obj)
           ^^^^^^^^^^^^^^^^^
TypeError: Integer exceeds 64-bit range

The problematic message. See "random_number": 65810885944677670000000000000000000000000000000000000000000000000000000000000.

@odesenfans odesenfans added the bug Something isn't working label Sep 15, 2023
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

1 participant