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

Invisible error for first paediatric assessment date before cohort 5 #1176

Open
mbarton opened this issue Jan 17, 2025 · 0 comments · May be fixed by #1178
Open

Invisible error for first paediatric assessment date before cohort 5 #1176

mbarton opened this issue Jan 17, 2025 · 0 comments · May be fixed by #1178

Comments

@mbarton
Copy link
Member

mbarton commented Jan 17, 2025

I've seen someone in the production logs try to set a first paediatric assessment date in 2016. We don't want to accept that on the platform as it's not in a cohort open for submission. But for the user it silently fails - they click the button and nothing happens.

It also causes an unhandled exception in the backend:

django-1   |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
django-1   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/decorator.py", line 398, in wrapper
django-1   |     return view(request, *args, **kwargs)
django-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/decorator.py", line 309, in wrapper
django-1   |     return view(request, *args, **kwargs)
django-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/usr/local/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 60, in _view_wrapper
django-1   |     return view_func(request, *args, **kwargs)
django-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/views/registration_views.py", line 619, in first_paediatric_assessment_date
django-1   |     validate_and_update_model(
django-1   |   File "/app/epilepsy12/common_view_functions/validate_form_update_model.py", line 149, in validate_and_update_model
django-1   |     child_cohort_data = cohorts_and_dates(
django-1   |                         ^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/general_functions/cohort_number.py", line 154, in cohorts_and_dates
django-1   |     "grace_cohort": dates_for_cohort(cohort=submitting_cohort_number - 1),
django-1   |                                             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
django-1   | TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
django-1   | ERROR [django.server] "POST /case/1/first_paediatric_assessment_date HTTP/1.1" 500 104032

We should fix the crash and ensure we show a useful error message to the user

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 a pull request may close this issue.

1 participant