Skip to content

Commit

Permalink
feat: return 404 for missing files (INFRA-735) (#465)
Browse files Browse the repository at this point in the history
* feat: return 404 for missing files (INFRA-735)

Technically, the underlying function checks for file accessibility, but
an internal server error would be inappropriate even then.

* update test description
  • Loading branch information
siers authored Jan 24, 2025
1 parent 4231f00 commit f54356f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SipiHttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ static void serve_info_json_file(Connection &conn_obj,
try {
access = check_file_access(conn_obj, serv, luaserver, params, prefix_as_path);
} catch (SipiError &err) {
send_error(conn_obj, Connection::INTERNAL_SERVER_ERROR, err);
send_error(conn_obj, Connection::NOT_FOUND, err);
return;
}

Expand Down
5 changes: 5 additions & 0 deletions test/e2e/test_02_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ def test_deny(self, manager):
manager.expect_status_code(
"/knora/DenyLeaves.jpg/full/max/0/default.jpg", 401)

def test_not_found(self, manager):
"""return 404 Not Found if the file is missing. Sipi will try and fail to find this file in the image directory."""
manager.expect_status_code(
"/file-should-be-missing-123", 404)

def test_iiif_url_parsing(self, manager):
"""Return 400 for invalid IIIF URL's"""
manager.expect_status_code("/unit//lena512.jp2", 400)
Expand Down

0 comments on commit f54356f

Please sign in to comment.