Skip to content

fix uncaught user input processing in date util #1373

Open
@melange396

Description

@melange396

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 in server/utils/dates.py:time_value_to_day()) can be wrapped to catch exceptions and then rethrow them as ValidationFailedexceptions. This is similar to what is done in other input processing methods in server/_params.py; those exceptions extend HTTPException 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 in time_value_to_week() as well, because i presume that will fail in an analogous way on unchecked/raw user input values.

Metadata

Metadata

Assignees

Labels

api changeaffect the API and its responsesbugpythonPull requests that update Python code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions