-
-
Couldn't load subscription status.
- Fork 5
Open
Labels
P3Low priority tasks.Low priority tasks.area: form submissionCode relating to the response submission to forms backend.Code relating to the response submission to forms backend.area: validationCode relating to validation of user input and Pydantic models.Code relating to validation of user input and Pydantic models.triageIssues that require triage attentionIssues that require triage attentiontype: bugA bug that needs fixing!A bug that needs fixing!
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 strFiles
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.
Metadata
Metadata
Assignees
Labels
P3Low priority tasks.Low priority tasks.area: form submissionCode relating to the response submission to forms backend.Code relating to the response submission to forms backend.area: validationCode relating to validation of user input and Pydantic models.Code relating to validation of user input and Pydantic models.triageIssues that require triage attentionIssues that require triage attentiontype: bugA bug that needs fixing!A bug that needs fixing!