Bug 29970 - 500 Error when a record cannot be displayed
Summary: 500 Error when a record cannot be displayed
Status: RESOLVED DUPLICATE of bug 29690
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Keywords:
Depends on: 11175 28734
Blocks:
  Show dependency treegraph
 
Reported: 2022-01-28 18:08 UTC by Nick Clemens
Modified: 2022-02-02 14:09 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 29970: eval processing of MARC record to avoid crash (3.17 KB, patch)
2022-02-02 13:40 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2022-01-28 18:08:26 UTC
When a record cannot be decoded Koha shows a 500 error to the user.

The code throws a Koha::Exceptions::Metadata::Invalid which is recorded in the plack-error

We should catch the exception and provide a better message to the user.

Often, these records will load in the editor, we should provide a link to the user so they can attempt to fix the record

Alternately, we should attempt to assume the record is encoded in a different format (marc8) and attempt to convert uft-8
Comment 1 Valerie 2022-01-28 19:27:46 UTC
This would be much more helpful than the 500 Error.
Comment 2 Nick Clemens 2022-02-02 13:40:10 UTC
Created attachment 130104 [details] [review]
Bug 29970: eval processing of MARC record to avoid crash

detail.pl displays a warning at the top of the page when a record contains parsing errors

Bug 28734 and bug 11175 added additional parsing of the MARC record, but
they did not catch the thrown errors.

The existing pattern in the script is to eval responses to avoid crashing

This patch wraps the new calls in eval{}

To test:
1 - Find a record in the staff catalog
2 - Edit the record
3 - In the 520 notes field, add an ASCII escape character (27 decimal, 1b hex)
    On ubuntu Ctrl+Shift+u, then 1b, enter
4 - Save the record
5 - 500 Error
6 - Apply patch
7 - Reload
8 - The record displays with a warning at the top
Comment 3 Jonathan Druart 2022-02-02 14:08:21 UTC
I don't understand, we were supposed to have fixed that few days ago, with bug 29690.

If the problem still persists, please have a look at the solution there (test $marc_record)
Comment 4 Jonathan Druart 2022-02-02 14:09:51 UTC
You patch does not apply, I think it's a duplicate.

*** This bug has been marked as a duplicate of bug 29690 ***