[Bug 44122] New: Pages die with an uncaught Koha::Exceptions::Metadata::Invalid when the metadata of a record cannot be repaired
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44122 Bug ID: 44122 Summary: Pages die with an uncaught Koha::Exceptions::Metadata::Invalid when the metadata of a record cannot be repaired Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: MARC Bibliographic data support Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Depends on: 43777 Target Milestone: --- Since bug 43777, Koha::Biblio::Metadata->record repairs recoverable MARCXML faults on read, and throws Koha::Exceptions::Metadata::Invalid for metadata that cannot be recovered at all (for example truncated MARCXML). The follow-ups of bug 43025 handle that exception in some places (merge, batch import, maintenance scripts, Z39.50 results, svc/bib and, with bug 44070, the staff detail page), but most pages that read the record do not, and die with an uncaught exception. To reproduce: 1. Pick a record that has an item and cut its MARCXML: UPDATE biblio_metadata SET metadata = SUBSTRING_INDEX(metadata, '</record>', 1) WHERE biblionumber = 1; 2. Open the pages below (bug 44070 applied, so catalogue/detail.pl works). Staff interface, all return a 500 with the uncaught Koha::Exceptions::Metadata::Invalid: - catalogue/MARCdetail.pl - catalogue/ISBDdetail.pl - catalogue/labeledMARCdetail.pl - catalogue/moredetail.pl - catalogue/showmarc.pl (html, marc, xml and card) - cataloguing/additem.pl - cataloguing/addbiblio.pl?biblionumber=1: "Can't call method "title" on an undefined value" at line 668 (the editor reads the record in an eval, and then does not check it) OPAC, all return a 500 with the exception: - opac-detail.pl - opac-MARCdetail.pl - opac-ISBDdetail.pl - opac-showmarc.pl - opac-basket.pl - opac-export.pl REST API: GET /api/v1/biblios/1 returns a 500, in JSON and in MARCXML. These work: catalogue/search.pl and opac-search.pl (they use the search engine records), catalogue/issuehistory.pl, reserve/request.pl, cataloguing/merge.pl (bug 43027). About 100 scripts and modules call ->metadata->record and only a few of them are guarded. For a patron the OPAC pages are the most visible: a record that cannot be read gives an error page instead of the usual "not available". Proposal: - OPAC: handle the exception like a record that does not exist (the existing not found page), and log the error for the library. - Staff interface: show the encoding error notice that catalogue/detail.pl shows (bug 44070) instead of the error, and render what can be rendered (the items, for moredetail.pl and additem.pl). - cataloguing/addbiblio.pl: do not read the title of a record that could not be read. - REST API: return an error that says that the metadata of the record cannot be read. See also bugs 43777, 43025 and 44070. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43777 [Bug 43777] Koha::Biblio::Metadata->record should repair recoverable MARCXML faults on read -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44122 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |43025 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43025 [Bug 43025] Show metadata repair warnings in the cataloguing edit form -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44122 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=44070, | |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=30043 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44122 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211732 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211732&action=edit Bug 44122: Handle unreadable record metadata in the catalogue and OPAC scripts When the MARCXML of a record is damaged beyond repair, Koha::Biblio::Metadata->record throws Koha::Exceptions::Metadata::Invalid. Most of the scripts that read it did not catch the exception, so the librarian got a 500 error page. This adds C4::Output::output_and_exit_if_invalid_metadata. It logs the exception and then, in the staff interface, shows a blocking message (new 'invalid_metadata' case in blocking_errors.inc) or, in the OPAC, redirects to the 404 page. Other exceptions are rethrown. It is used by the staff scripts ISBDdetail, MARCdetail, labeledMARCdetail, moredetail, showmarc and additem and by the OPAC scripts opac-detail, opac-MARCdetail, opac-ISBDdetail, opac-showmarc and opac-export. opac-basket skips the unreadable record. addbiblio now stops after showing its existing notice for records that cannot be repaired instead of failing further down. The detail.pl script is handled by bug 44070. To test: 1. Damage the metadata of a record that has an item: UPDATE biblio_metadata SET metadata=SUBSTRING(metadata,1,60) WHERE biblionumber=X; 2. In the staff interface open for this record: MARC preview, ISBD preview, labeled MARC preview, Items (moredetail), Edit items and Edit record, and the MARC popup from the search results. => A message is shown, no 500 error 3. In the OPAC open the details, MARC view and ISBD view of the record => You are sent to the page not found page 4. Add the record to the basket and open the basket => The page loads, without the record 5. Check a healthy record still works everywhere 6. prove t/Output.t 7. yarn cypress run --spec t/cypress/integration/InvalidMetadata_spec.ts -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44122 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44122 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |adolfo.rodriguez@xercode.es --- Comment #2 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Testing notes: most of it works nicely. With a record whose MARCXML was cut, MARC/ISBD/labeled MARC/moredetail/additem show the new message instead of a 500, the OPAC detail/MARC/ISBD/showmarc/export pages redirect to the 404 page, the basket loads without the damaged record, the error is logged with the biblionumber, and t/Output.t and the QA tools pass. One problem in cataloguing/addbiblio.pl: the page shows the "cannot be loaded for editing" notice, but the template still renders the "Add MARC record" toolbar and an empty form below it, without the biblionumber (the script exits before setting it). Clicking Save creates a new, empty bibliographic record. On main the page died, so this is new with the patch. I think the template should stop after the notice, as blocking_errors.inc does (INCLUDE 'intranet-bottom.inc' + STOP inside the INVALID_METADATA block). Minor: the search pages load showmarc.pl with .load(page + " div"), so in the MARC preview modal the message would be followed by the divs of intranet-bottom.inc that blocking_errors.inc includes (language bar, cookie consent). Not a blocker, just mentioning it. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org