https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43023 --- Comment #2 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 211589 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211589&action=edit Bug 43023: Skip undecodable records instead of aborting search results A single record whose stored MARC cannot be decoded can make the whole page of search results die. Several paths decode each hit without any guard: - C4::Search::searchResults, the scan branch, calls MARC::Record->new_from_usmarc on every raw scan result with no eval. - C4::Search::new_record_from_zebra, the Elasticsearch fast path, returns MARC::Record->new_from_xml without the eval that the Zebra DOM and GRS-1 branches already have. - Koha::SearchEngine::Elasticsearch::Search::search_compat decodes each hit with decode_record_from_result, with no eval, so one bad hit aborts the whole result set. - opac/opac-search.pl decodes the supplemental authority results without a guard. Each of these now logs the record that failed and skips it, so the rest of the page still renders. search_compat leaves an undefined hole at the failed position so that offsets still line up with the page being rendered. searchResults and Koha::Biblio->get_marc_components skip those holes. This follows the same per-record isolation as the existing Zebra branches, which already skip undecodable records. To test: 1. Run prove t/db_dependent/Search/UndecodableRecords.t inside KTD. Before this patch it dies on the malformed scan record. After it all 12 tests pass. 2. Optional, on a Zebra install: run a scan search and a normal search that includes a record with corrupt stored metadata. Before the patch the results page can die. After it, the bad record is missing from the list and the rest render, with an "ERROR DECODING" line in the log. 3. Optional, on an Elasticsearch install: index a record whose marc_data is not valid MARCXML or ISO2709, then run a search that returns it. The other results should still render. Sponsored-by: OpenFifth Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> -- You are receiving this mail because: You are watching all bug changes.