Bug 73 - /modalities/{modalityId}/store raises 500 errors instead of 404
Summary: /modalities/{modalityId}/store raises 500 errors instead of 404
Status: RESOLVED FIXED
Alias: None
Product: Orthanc
Classification: Unclassified
Component: Orthanc Core (show other bugs)
Version: unspecified
Hardware: All All
: --- minor
Assignee: Sébastien Jodogne
URL:
Depends on:
Blocks:
 
Reported: 2020-06-29 15:13 CEST by Sébastien Jodogne
Modified: 2020-06-29 15:24 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sébastien Jodogne 2020-06-29 15:13:18 CEST
[BitBucket user: Alain Mazy]
[BitBucket date: 2017-11-10.16:52:32]

- When trying to store a study that does not exist, we get a 500 response
- When trying to store a study that exists to a modalityId that does not exist, we get a 500 response.

In both cases, we should get a 404 and eventually a detail telling us what is not found.
Comment 1 Sébastien Jodogne 2020-06-29 15:24:33 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-01-25.09:24:48]

The second part of this issue (storing an existing study to an inexistent modality, in this case "nope") is solved since at least Orthanc 1.0.0 .

```text
$ sudo docker run -p 4242:4242 -p 8042:8042 --rm jodogne/orthanc:1.5.2
$ curl -u orthanc:orthanc http://localhost:8042/modalities/nope/store -X POST -d '19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5' -i
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Length: 293

{
   "Details" : "No modality with symbolic name: nope",
   "HttpError" : "Not Found",
   "HttpStatus" : 404,
   "Message" : "Accessing an inexistent item",
   "Method" : "POST",
   "OrthancError" : "Accessing an inexistent item",
   "OrthancStatus" : 7,
   "Uri" : "/modalities/nope/store"
}
```
Comment 2 Sébastien Jodogne 2020-06-29 15:24:36 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-01-25.12:10:57]

Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)

→ https://hg.orthanc-server.com/orthanc/changeset/860aed8258c3
Comment 3 Sébastien Jodogne 2020-06-29 15:24:37 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-01-25.12:15:57]

This issue was essentially a missing description of the error message. This is now fixed:

```text
# Test with a invalid Orthanc identifier (results in a 400 error without body in Orthanc <= 1.5.2):
$ curl http://localhost:8042/modalities/self/store -X POST -d '["19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f"]' -i
HTTP/1.1 400 Bad Request
Connection: keep-alive
Content-Length: 324

{
   "Details" : "This string is not a valid Orthanc identifier: 19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f",
   "HttpError" : "Bad Request",
   "HttpStatus" : 400,
   "Message" : "Bad file format",
   "Method" : "POST",
   "OrthancError" : "Bad file format",
   "OrthancStatus" : 15,
   "Uri" : "/modalities/self/store"
}

# Test with a valid Orthanc identifier, but nonexistent DICOM instance:
$ curl http://localhost:8042/modalities/self/store -X POST -d '["19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f6"]' -i
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Length: 215

{
   "HttpError" : "Not Found",
   "HttpStatus" : 404,
   "Message" : "Unknown resource",
   "Method" : "POST",
   "OrthancError" : "Unknown resource",
   "OrthancStatus" : 17,
   "Uri" : "/modalities/self/store"
}
```