Bug 143 - WADO-RS metadata request returns "500 Internal Server Error" instead of "404 Not Found" for missing instance
Summary: WADO-RS metadata request returns "500 Internal Server Error" instead of "404 ...
Status: RESOLVED FIXED
Alias: None
Product: Orthanc
Classification: Unclassified
Component: Plugin - DICOMweb (show other bugs)
Version: unspecified
Hardware: All All
: --- normal
Assignee: Sébastien Jodogne
URL:
Depends on:
Blocks:
 
Reported: 2020-06-29 15:15 CEST by Sébastien Jodogne
Modified: 2020-06-29 15:25 CEST (History)
0 users

See Also:


Attachments
PM5644-960x540_RGB.dcm (1.48 MB, application/dicom)
2020-06-29 15:17 CEST, Sébastien Jodogne
Details

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:15:49 CEST
[BitBucket user: Bernd Kuemmerlen]
[BitBucket date: 2019-06-19.15:58:39]

When requesting metadata for a non-existing SOPInstanceUID through WADO-RS, the server returns “500 Internal Server Error” instead of “404 Not Found“. 

Non-existant UIDs on Study or Series level return the correct “404 Not Found”, but only if the SOPInstanceUID is available.

Clients relying on the correct http status codes will be confused by this.

#### Steps to Reproduce

* Import the attached test image PM5644-960x540\_RGB.dcm into Orthanc
* Request metadata for instance from DICOMWeb server:

    * http://localhost:8042/dicom-web/studies/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.2/series/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.3/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata
    
        * => The request results in “200 OK” and the metadata is returned :white_check_mark: 
        
    
* Change StudyInstanceUID to something which is not available:

    * [http://localhost:8042/dicom-web/studies/**0.0.0.0.0**/series/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.3/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata](http://localhost:8042/dicom-web/studies/0.0.0.0.0/series/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.3/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata)
    
        * => The request results in “404 Not Found”, and the OrthancError “Accessing an inexistant item” is returned :white_check_mark: 
        * The Details say `"No instance 1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754 in study 0.0.0.0.0 or in series 1.3.6.1.4.1.34261.90254037371867.41912.1553085024.3"`, which seems only partly correct, because the instance `1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754` is available in series `1.3.6.1.4.1.34261.90254037371867.41912.1553085024.3`, but the message says **or**, so technically, the message is wrong. :exclamation: 
        * The server logs `E0619 15:46:17.728911 PluginsErrorDictionary.cpp:111] Exception inside the plugin engine: Accessing an inexistent item` :white_check_mark: 
        
    
* Change SeriesInstanceUID to something which is not available:

    * [http://localhost:8042/dicom-web/studies/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.2/series/**0.0.0.0.0**/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata](http://localhost:8042/dicom-web/studies/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.2/series/0.0.0.0.0/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata)
    
        * => The request results in “404 Not Found”, and the OrthancError “Accessing an inexistant item” is returned :white_check_mark: 
        * The Details say `"No instance 1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754 in study 1.3.6.1.4.1.34261.90254037371867.41912.1553085024.2 or in series 0.0.0.0.0"`, which seems only partly correct, because the instance `1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754` is available in study`1.3.6.1.4.1.34261.90254037371867.41912.1553085024.2`, but the message says **or**, so technically, the message is wrong. :exclamation: 
        * The server logs `E0619 15:46:17.728911 PluginsErrorDictionary.cpp:111] Exception inside the plugin engine: Accessing an inexistent item` :white_check_mark: 
        
    
* Change SOPInstanceUID to something which is not available:

    * [http://localhost:8042/dicom-web/studies/1.2.840.113619.2.55.3.671756986.106.1316467036.460/series/1.2.840.113619.2.55.3.671756986.106.1316467036.465/instances/**0.0.0.0.0**/metadata](http://localhost:8042/dicom-web/studies/1.2.840.113619.2.55.3.671756986.106.1316467036.460/series/1.2.840.113619.2.55.3.671756986.106.1316467036.465/instances/0.0.0.0.0/metadata)
    
        * The request results in “500 Internal Server Error” :bangbang: 
        * The server logs `E0619 15:47:52.640130 PluginsErrorDictionary.cpp:111] Exception inside the plugin engine: Internal error`
        
    
* Change all UIDs to something which is not available:

    * [http://localhost:8042/dicom-web/studies/**0.0.0.0.0**/series/**0.0.0.0.0**/instances/**0.0.0.0.0**/metadata](http://localhost:8042/dicom-web/studies/0.0.0.0.0/series/0.0.0.0.0/instances/0.0.0.0.0/metadata)
    
        * The request results in “500 Internal Server Error” :bangbang: 
        * The server logs `E0619 15:47:52.640130 PluginsErrorDictionary.cpp:111] Exception inside the plugin engine: Internal error`
        
    

#### Expected Results

* The following requests should result in a “404 Not Found” response from the server:

    * [[http://localhost:8042/dicom-web/studies/1.2.840.113619.2.55.3.671756986.106.1316467036.460/series/1.2.840.113619.2.55.3.671756986.106.1316467036.465/instances/](http://localhost:8042/dicom-web/studies/1.2.840.113619.2.55.3.671756986.106.1316467036.460/series/1.2.840.113619.2.55.3.671756986.106.1316467036.465/instances/)**0.0.0.0.0**/metadata](http://localhost:8042/dicom-web/studies/1.2.840.113619.2.55.3.671756986.106.1316467036.460/series/1.2.840.113619.2.55.3.671756986.106.1316467036.465/instances/0.0.0.0.0/metadata)
    * [http://localhost:8042/dicom-web/studies/**0.0.0.0.0**/series/**0.0.0.0.0**/instances/**0.0.0.0.0**/metadata](http://localhost:8042/dicom-web/studies/0.0.0.0.0/series/0.0.0.0.0/instances/0.0.0.0.0/metadata)
    

#### Environment

This is reproducible on Orthanc 1.5.6, running from the jodogne/orthanc-plugins Docker image
Comment 1 Sébastien Jodogne 2020-06-29 15:17:28 CEST
Created attachment 42 [details]
PM5644-960x540_RGB.dcm
Comment 2 Sébastien Jodogne 2020-06-29 15:25:51 CEST
[BitBucket user: Bernd Kuemmerlen]
[BitBucket date: 2019-06-20.07:21:33]

This works as expected in an earlier version of Orthanc. Unfortunately, I did not find a way of determining the version in which this works, if anyone can give me a pointer where to look, I can report the version.

Edit: From the installation date, I suspect that the installation where this works is around Orthanc 1.3.1
Comment 3 Sébastien Jodogne 2020-06-29 15:25:52 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-06-21.16:29:51]

Thanks for this very precise bug report! Here are the 3 related changesets that should fix this issue.

Fix in Orthanc SDK C++ wrapper: https://hg.orthanc-server.com/orthanc/changeset/77702c19a2fad01a424e12d95cd8f439aa474ccb

Fix of logs in DICOMweb plugin: https://hg.orthanc-server.com/orthanc-dicomweb/changeset/b995fc9156de4dfb9a0776b9258d886711af4891

Integration test: https://hg.orthanc-server.com/orthanc-tests/changeset/e4e0e2ff91ae99e8c5789adc4c5368b37a030eca