You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An improperly formatted date causes an uninformative 500 error, and a useful message should instead be bubbled up to the user with a better error code.
Itll also be good practice to first add a test that fails for this, then do the fix, then make sure the test now passes
Actually, we already have tests for utils/dates.pyhere.
We also have integration test for the /csv endpoint here.
Here are list of params that were provided by user:
start_day=2023-01-01
end_day=2024-18-01 <----- the wrong date format, probably user missmatched date format, because we have YY-MM-DD.
geo_type=county
signal=chng:smoothed_outpatient_cli
An improperly formatted date causes an uninformative 500 error, and a useful message should instead be bubbled up to the user with a better error code.
This was brought to our attention by sentry, see: https://cmu-delphi.sentry.io/issues/4893721093/
One way to fix this: the offending
date()
constructor call that puked here (found inserver/utils/dates.py:time_value_to_day()
) can be wrapped to catch exceptions and then rethrow them asValidationFailedexception
s. This is similar to what is done in other input processing methods inserver/_params.py
; those exceptions extendHTTPException
which is handled and presented to the user gracefully by the web server.We probbly also wanna do it with the similar
Week()
constructor call intime_value_to_week()
as well, because i presume that will fail in an analogous way on unchecked/raw user input values.The text was updated successfully, but these errors were encountered: