Bug 24243 - Bad characters in MARC cause internal server error when searching catalog
Summary: Bad characters in MARC cause internal server error when searching catalog
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-13 18:30 UTC by Nick Clemens
Modified: 2019-12-23 17:54 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.01


Attachments
Bug 24243: Do not explode if invalid metadata when searching catalogue (1.85 KB, patch)
2019-12-15 11:58 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24243: Do not explode if invalid metadata when searching catalogue (1.90 KB, patch)
2019-12-16 14:23 UTC, Liz Rea
Details | Diff | Splinter Review
Bug 24243: Do not explode if invalid metadata when searching catalogue (1.95 KB, patch)
2019-12-22 13:38 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 Nick Clemens 2019-12-13 18:30:08 UTC
Koha::Biblio::Metadata::record can throw an exception, it must always be caught

If CoinsInOpac is enabled we call 'get_coins' on the search results - get_coins calls for the record.

On the staff details page this exception is handled but not in opac results.
Comment 1 Jonathan Druart 2019-12-15 11:58:29 UTC
Created attachment 96295 [details] [review]
Bug 24243: Do not explode if invalid metadata when searching catalogue

If the bibliographic record metadata cannot be decoded, the get_coins
call should catch the exception raised by Koha::Biblio::Metadata->record
to not explode

Error is: "Invalid data, cannot decode objec"

Test plan:
0/ Do not apply the patch
1/ Search for record at the OPAC
2/ Note one of the biblionumber from the first page result
3/ Set to empty string the biblio_metadata to make the error appears:
  update biblio_metadata set metadata="" where biblionumber=42;
4/ Try the same search
=> You get an internal server error
5/ Apply the patch, restart plack and try again
=> It now works, ie. it does not explode
Comment 2 Liz Rea 2019-12-16 13:43:05 UTC
this happens in the record exporter as well.
Comment 3 Liz Rea 2019-12-16 14:23:44 UTC
Created attachment 96340 [details] [review]
Bug 24243: Do not explode if invalid metadata when searching catalogue

If the bibliographic record metadata cannot be decoded, the get_coins
call should catch the exception raised by Koha::Biblio::Metadata->record
to not explode

Error is: "Invalid data, cannot decode objec"

Test plan:
0/ Do not apply the patch
1/ Search for record at the OPAC
2/ Note one of the biblionumber from the first page result
3/ Set to empty string the biblio_metadata to make the error appears:
  update biblio_metadata set metadata="" where biblionumber=42;
4/ Try the same search
=> You get an internal server error
5/ Apply the patch, restart plack and try again
=> It now works, ie. it does not explode

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Comment 4 Nick Clemens 2019-12-16 14:24:35 UTC
Shouldn't we log the error?
Comment 5 Jonathan Druart 2019-12-16 14:51:56 UTC
(In reply to Nick Clemens from comment #4)
> Shouldn't we log the error?

There is a check in search_for_data_inconsistencies.pl, so I'd say it's not needed.
Comment 6 Liz Rea 2019-12-16 15:58:52 UTC
From a troubleshooting point of view, that would be nice.
Comment 7 Jonathan Druart 2019-12-16 17:58:13 UTC
There will be a warning on the detail page of the problematic record anyway (from bug 23846)
Comment 8 Katrin Fischer 2019-12-22 13:38:31 UTC
Created attachment 96573 [details] [review]
Bug 24243: Do not explode if invalid metadata when searching catalogue

If the bibliographic record metadata cannot be decoded, the get_coins
call should catch the exception raised by Koha::Biblio::Metadata->record
to not explode

Error is: "Invalid data, cannot decode objec"

Test plan:
0/ Do not apply the patch
1/ Search for record at the OPAC
2/ Note one of the biblionumber from the first page result
3/ Set to empty string the biblio_metadata to make the error appears:
  update biblio_metadata set metadata="" where biblionumber=42;
4/ Try the same search
=> You get an internal server error
5/ Apply the patch, restart plack and try again
=> It now works, ie. it does not explode

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Katrin Fischer 2019-12-22 13:39:44 UTC
Maybe we should think about displaying a more specific error, currently in the intranet you see:
The record you requested does not exist (2).

It's not quite correct.
Comment 10 Martin Renvoize 2019-12-23 11:09:05 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 11 Lucas Gass 2019-12-23 17:29:00 UTC
backported to 19.11.x for 19.11.01
Comment 12 Lucas Gass 2019-12-23 17:29:18 UTC
backported to 19.05.x for 19.05.06
Comment 13 Joy Nelson 2019-12-23 17:54:34 UTC
Pushed to 19.11.01