Bug 33047 - Local cover image fetchers return 500 internal error when image not available
Summary: Local cover image fetchers return 500 internal error when image not available
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Jonathan Druart
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-22 20:29 UTC by Galen Charlton
Modified: 2023-12-28 20:47 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.02,22.11.08
Circulation function:


Attachments
Bug 33047: Return 404 instead of 500 when biblio does not exist (4.58 KB, patch)
2023-05-11 13:51 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33047: Return 404 instead of 500 when biblio does not exist (4.62 KB, patch)
2023-06-15 16:48 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 33047: Return 404 instead of 500 when biblio does not exist (4.68 KB, patch)
2023-07-09 15:09 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Galen Charlton 2023-02-22 20:29:09 UTC
Because of an uncaught exception, both catalogue/image.pl and opac/opac-image.pl return 500 errors when asked to provide the image by biblionumber for a bib that does not exist.


This is a bit untidy; if the bib does not exist, *image.pl should either return the default one-pixel image or perhaps a 404, but not the error page.

This normally isn't a huge deal when the local cover images are displayed by the staff or public catalog, as both of those interfaces inherently only display bibs that are known to exist.

However, since it is possible for external clients to want to get at local cover images (e.g., see https://github.com/vufind-org/vufind/pull/2444), better provision should be made if the client requests the local cover of a nonexisting bib (e.g., if the bib had been deleted since the last time that the external client got knowledge of it).
Comment 1 Jonathan Druart 2023-05-11 13:51:48 UTC
Created attachment 151082 [details] [review]
Bug 33047: Return 404 instead of 500 when biblio does not exist

If the biblionumber or the itemnumber passed in parameter does not
exist we should return 404 instead of exploding with a 500.

Test plan:
Attach cover images to biblio and items
Notice that the UI is working correctly (staff and OPAC)
Hit catalogue/image.pl and opac/opac-image.pl with non-existent
biblionumber and imagenumber
Notice that you now get 404 instead of 500
Comment 2 Jonathan Druart 2023-05-11 13:52:09 UTC
Galen, would that work for you?
Comment 3 Owen Leonard 2023-06-15 16:48:47 UTC
Created attachment 152390 [details] [review]
Bug 33047: Return 404 instead of 500 when biblio does not exist

If the biblionumber or the itemnumber passed in parameter does not
exist we should return 404 instead of exploding with a 500.

Test plan:
Attach cover images to biblio and items
Notice that the UI is working correctly (staff and OPAC)
Hit catalogue/image.pl and opac/opac-image.pl with non-existent
biblionumber and imagenumber
Notice that you now get 404 instead of 500

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 4 Katrin Fischer 2023-07-09 15:09:23 UTC
Created attachment 153226 [details] [review]
Bug 33047: Return 404 instead of 500 when biblio does not exist

If the biblionumber or the itemnumber passed in parameter does not
exist we should return 404 instead of exploding with a 500.

Test plan:
Attach cover images to biblio and items
Notice that the UI is working correctly (staff and OPAC)
Hit catalogue/image.pl and opac/opac-image.pl with non-existent
biblionumber and imagenumber
Notice that you now get 404 instead of 500

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Tomás Cohen Arazi (tcohen) 2023-07-10 18:43:01 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 6 Martin Renvoize (ashimema) 2023-07-18 09:33:26 UTC
Thanks for all the hard work!

Pushed to 23.05.x for the next release
Comment 7 Matt Blenkinsop 2023-07-18 14:07:07 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x