Commit c7498dc
authored
fix(submission): handle missing xml file with digest authentication DEV-1038 (#6428)
### 📣 Summary
Prevent server errors when clients using Digest authentication send
empty submission requests to the openrosa `/<username>/submission`
endpoint.
### 📖 Description
Previously, when a client (such as curl using --digest) attempted to
submit to `https://kobocat/<username>/submission` for a form that does
not allow anonymous submissions, the first unauthenticated request in
the Digest handshake was accepted by the view.
Because this initial request contained no body and no authentication
header, the view attempted to read a `None` file instance, leading to:
```
AttributeError: 'NoneType' object has no attribute 'read'
```
This caused a 500 error before the client’s second (authenticated)
request could be processed.
This PR adds a validation to check whether `xml_file` is missing or
empty. When this happens, the server now fails fast with a proper
`OpenRosaResponseBadRequest (400)` and a clear, informative error
message.1 parent 48e95bf commit c7498dc
File tree
2 files changed
+41
-0
lines changed- kobo/apps/openrosa/apps/api
- tests/viewsets
- viewsets
2 files changed
+41
-0
lines changedLines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
924 | 958 | | |
925 | 959 | | |
926 | 960 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
249 | 250 | | |
250 | 251 | | |
251 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
252 | 259 | | |
253 | 260 | | |
254 | 261 | | |
| |||
0 commit comments