Open
Description
Description
Submitting a non mapping response to a form, such as a list, returns a 500 error. It should return a 4xx error.
Reproduction Steps
- Create a form with no required questions
- Submit an empty response to that form on the
/forms/submit/<form_name>
endpoint. See request body below. - The server should return a 500 error, and should generate a traceback on the backend (see below).
Request body:
{
"response": []
}
Traceback:
File ".\backend\routes\forms\submit.py", line 115, in post
response["response"][question.id] = None
TypeError: list indices must be integers or slices, not str
Files
No response
Technical Details
We are trying to access fields of the response, without checking if it is a mapping. When passing in a list, a TypeError
is generated.
Ideally, the fix will be a validator on the form_response model.