https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43023

--- Comment #4 from Andrew Fuerste-Henry <[email protected]> ---
Created attachment 212446
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212446&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 <[email protected]>
Signed-off-by: Adolfo Rodríguez <[email protected]>
Signed-off-by: Andrew Fuerste Henry <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to