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

OverflowErrors and 500 on home page when setting max expiry offset to extremely large numbers #427

Closed
helpimnotdrowning opened this issue Dec 23, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@helpimnotdrowning
Copy link

As a new user, I'm looking for a fileshare that doesn't auto-expire my uploaded files (single-user). In exploring the app settings before I use it, I set "Maximum Expiry Offset (hours)" to "99999999999999999999999999999999999999".
image

This results a home page with only the text "Server Error (500)"
image
, and the following error printed to the docker log:

Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.13/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/contrib/auth/mixins.py", line 73, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/edit.py", line 142, in get
    return self.render_to_response(self.get_context_data())
                                   ~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/app/web/shifter_files/views.py", line 52, in get_context_data
    context = super().get_context_data(**kwargs)
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/edit.py", line 72, in get_context_data
    kwargs["form"] = self.get_form()
                     ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/edit.py", line 37, in get_form
    return form_class(**self.get_form_kwargs())
  File "/home/app/web/shifter_files/forms.py", line 38, in __init__
    exp_date_max = timezone.now() + timedelta(
                                    ~~~~~~~~~^
        hours=int(SiteSetting.get_setting("max_expiry_offset"))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
OverflowError: Python int too large to convert to C int

Using a value of 2147483646 (less than the 32bit signed int limit) gives a different OverflowError:

Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.13/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/contrib/auth/mixins.py", line 73, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/edit.py", line 142, in get
    return self.render_to_response(self.get_context_data())
                                   ~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/app/web/shifter_files/views.py", line 52, in get_context_data
    context = super().get_context_data(**kwargs)
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/edit.py", line 72, in get_context_data
    kwargs["form"] = self.get_form()
                     ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/django/views/generic/edit.py", line 37, in get_form
    return form_class(**self.get_form_kwargs())
  File "/home/app/web/shifter_files/forms.py", line 38, in __init__
    exp_date_max = timezone.now() + timedelta(
                   ~~~~~~~~~~~~~~~^~~~~~~~~~~~
        hours=int(SiteSetting.get_setting("max_expiry_offset"))
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    )
    ~
OverflowError: date value out of range
@helpimnotdrowning helpimnotdrowning changed the title OverflowError(s) and 500 on home page when setting max expiry offset to extremely large numbers OverflowErrors and 500 on home page when setting max expiry offset to extremely large numbers Dec 23, 2024
@TobySuch TobySuch added the bug Something isn't working label Dec 23, 2024
@TobySuch TobySuch self-assigned this Dec 23, 2024
TobySuch added a commit that referenced this issue Dec 24, 2024
…#429)

* Add max values to site settings

* Fix issue where max expiry would create too large date object
@TobySuch
Copy link
Owner

Hi! Thanks for the bug report.

Just released v0.4.1 - could you give that a try? I've fixed up the validation so you should get better errors at the least, and setting 2147483646 as the max expiry offset will give you enough headroom I hope!

I've also created #428 to follow up on making the expiry date fully optional. Thanks for the suggestion!

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