https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43021 Bug ID: 43021 Summary: A single malformed Z39.50/SRU result can break search and staged record preview Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Z39.50 / SRU / OpenSearch Servers Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl Depends on: 35104 Target Milestone: --- Two related, unguarded MARC decode calls in the Z39.50/SRU search and staged record ("breeding") preview flow: 1. C4::Breeding::_handle_one_result (C4/Breeding.pm) calls MARC::Record->new_from_xml on each SRU search result with no eval. The caller loop that iterates search results across all configured servers already has per-result error handling for other kinds of failures (connection diagnostics collected in @errconn), but this call bypasses it entirely - one malformed record from any searched server aborts the whole results page for the cataloguer running the search. 2. MARCfindbreeding in cataloguing/addbiblio.pl calls MARC::Record->new_from_usmarc on a staged ("breeding") record with no eval, when a cataloguer opens that staged record to preview/import it. Both should catch a decode failure for the one affected record and report it to the user (e.g. skip that result with a visible message, or show a clear error instead of a blank/broken page) rather than propagating an uncaught exception. Found while auditing other places in the codebase that ingest externally-sourced MARC data, prompted by bug 35104. Test plan: 1. Configure a Z39.50/SRU target and search it for records, where at least one result server returns a record whose MARC cannot be decoded (or simulate by mocking C4::Breeding::_handle_one_result's input). 2. Before a fix: the whole results page fails/errors out. 3. Separately, stage a file containing an undecodable record via Stage MARC records for import, then open it via the cataloguing "breeding" preview. 4. Before a fix: the preview page errors out. 5. After a fix: both cases show a clear per-record error and let the user continue working with the rest of the results/batch. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35104 [Bug 35104] We should warn when attempting to save MARC records that contain characters invalid in XML -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.