changeset 5997:3d8d227dd96f

return 404 instead of [] when calling e.g. /patients/not-a-patient-id/instances
author Alain Mazy <am@orthanc.team>
date Wed, 05 Feb 2025 16:14:25 +0100
parents 6ee625ebd09c
children c2fd0249996b
files OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Wed Feb 05 16:09:39 2025 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Wed Feb 05 16:14:25 2025 +0100
@@ -3615,6 +3615,14 @@
 
     Json::Value answer;
     finder.Execute(answer, OrthancRestApi::GetContext(call), format, false /* no "Metadata" field */);
+    
+    // Given the data model, if there are no children, it means there is no parent.
+    // https://discourse.orthanc-server.org/t/patients-id-instances-quirk/5498
+    if (answer.size() == 0) 
+    {
+      throw OrthancException(ErrorCode_UnknownResource);
+    }
+
     call.GetOutput().AnswerJson(answer);
   }