diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index b4c20f11beeec470008aab8886dbe1390e883794..230d476eb09467d7aa9347dac04e9264437c2b44 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -587,6 +587,8 @@ function system_file_download($uri): Response {
         if (array_intersect($parts, ['.', '..'])) {
           return -1;
         }
+        // Default response when the file is not found.
+        return new Response('File not found', 404);
       }
     }
   }