[Bug 44069] New: svc/bib still calls removed record_strip_nonxml and no longer reports repaired records
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Bug ID: 44069 Summary: svc/bib still calls removed record_strip_nonxml and no longer reports repaired records Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Cataloging 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 Target Milestone: --- Follow-up to bug 43777, reported by Adolfo Rodriguez on that bug. Bug 43777 made Koha::Biblio::Metadata->record() repair recoverable MARCXML faults on read and removed Koha::Biblio::Metadata->record_strip_nonxml. svc/bib (fetch_bib) was not adapted: - When metadata_record() throws Koha::Exceptions::Metadata::Invalid, fetch_bib still calls $biblio->metadata->record_strip_nonxml, which no longer exists. Unrecoverable records now die with a missing-method error instead of returning a proper error. - Recoverable records never reach that branch any more, because metadata_record() already returns the repaired record. The invalid_metadata header is therefore never sent, and the advanced cataloguing editor (koha-backend.js, GetRecord) no longer shows "Record had encoding issues, please switch to the basic editor to view details". Proposed fix: drop the record_strip_nonxml call and return a proper error response for unrecoverable records; set the invalid_metadata header when $biblio->metadata->object_messages is not empty, as Koha::OAI::Server::Repository->get_biblio_marcxml does. Test plan: 1. Apply the patch. 2. Create a record whose stored MARCXML contains a control character (e.g. 0x1F) in a subfield, directly in biblio_metadata. 3. Request /cgi-bin/koha/svc/bib/<biblionumber> and confirm the response carries the invalid_metadata header and the repaired record. 4. Open the record in the advanced cataloguing editor and confirm the encoding warning is shown. 5. Break the record so it cannot be repaired (truncated XML) and confirm svc/bib returns an error rather than a missing-method exception. 6. prove t/db_dependent/svc/bib.t (or the new test added by the patch) Sponsored-by: OpenFifth -- 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=44069 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk 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=44069 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211483 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211483&action=edit Bug 44069: Fix svc/bib for recoverable and unrecoverable records Koha::Biblio::Metadata->record() now repairs recoverable MARCXML faults on read and reports them through object_messages, and record_strip_nonxml() was removed. svc/bib still called the removed method when metadata_record() threw Koha::Exceptions::Metadata::Invalid, so unrecoverable records died with a missing-method error instead of returning a proper error. Recoverable records never reached that branch, so the invalid_metadata header was never set and the advanced cataloguing editor no longer warned about encoding issues. This change drops the record_strip_nonxml call and returns a 500 with an XML error body for unrecoverable records. The invalid_metadata header is now set from $biblio->metadata->object_messages, as Koha::OAI::Server::Repository->get_biblio_marcxml does. A new regression test, t/db_dependent/svc/bib.t, covers valid, recoverable, unrecoverable and unknown records. To test: 1. Apply the patch. 2. Create a record and store MARCXML with a control character (chr(31)) in a subfield directly in biblio_metadata. 3. Request /cgi-bin/koha/svc/bib/<biblionumber>. Confirm the response carries "Invalid-metadata: 1" and the repaired record. 4. Open the record in the advanced cataloguing editor and confirm the "Record had encoding issues" alert is shown. 5. Store truncated XML in biblio_metadata and request the same URL. Confirm a 500 with an XML error body, not a missing-method error. 6. Run: prove t/db_dependent/svc/bib.t Sponsored-by: OpenFifth Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |43642 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43642 [Bug 43642] Show metadata repair warnings in the advanced cataloguing editor -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Sponsorship status|--- |Sponsored Comma delimited| |OpenFifth list of Sponsors| | Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211483|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 --- Comment #2 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 211526 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211526&action=edit Bug 44069: Fix svc/bib for recoverable and unrecoverable records Koha::Biblio::Metadata->record() now repairs recoverable MARCXML faults on read and reports them through object_messages, and record_strip_nonxml() was removed. svc/bib still called the removed method when metadata_record() threw Koha::Exceptions::Metadata::Invalid, so unrecoverable records died with a missing-method error instead of returning a proper error. Recoverable records never reached that branch, so the invalid_metadata header was never set and the advanced cataloguing editor no longer warned about encoding issues. This change drops the record_strip_nonxml call and returns a 500 with an XML error body for unrecoverable records. The invalid_metadata header is now set from $biblio->metadata->object_messages, as Koha::OAI::Server::Repository->get_biblio_marcxml does. A new regression test, t/db_dependent/svc/bib.t, covers valid, recoverable, unrecoverable and unknown records. To test: 1. Apply the patch. 2. Create a record and store MARCXML with a control character (chr(31)) in a subfield directly in biblio_metadata. 3. Request /cgi-bin/koha/svc/bib/<biblionumber>. Confirm the response carries "Invalid-metadata: 1" and the repaired record. 4. Open the record in the advanced cataloguing editor and confirm the "Record had encoding issues" alert is shown. 5. Store truncated XML in biblio_metadata and request the same URL. Confirm a 500 with an XML error body, not a missing-method error. 6. Run: prove t/db_dependent/svc/bib.t 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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |adolfo.rodriguez@xercode.es --- Comment #3 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Tested in a sandbox instance with two records whose MARCXML was edited directly in biblio_metadata: - Repairable record (chr(31) in 245$a): - Before the patch, svc/bib returned the repaired record but the advanced editor showed no warning. - After the patch, the advanced editor shows "Record had encoding issues, please switch to the basic editor to view details". - Unrepairable record (truncated XML, no closing </record>): - Before the patch, svc/bib died with "The method Koha::Biblio::Metadata->record_strip_nonxml is not covered by tests!". - After the patch, it returns a 500 with the XML error body "Record metadata is invalid and could not be repaired". prove t/db_dependent/svc/bib.t passes, and the QA script is happy. Thanks for picking this up, Martin! Have a nice day. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |lucas@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211526|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44069 --- Comment #4 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- Created attachment 212303 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212303&action=edit Bug 44069: Fix svc/bib for recoverable and unrecoverable records Koha::Biblio::Metadata->record() now repairs recoverable MARCXML faults on read and reports them through object_messages, and record_strip_nonxml() was removed. svc/bib still called the removed method when metadata_record() threw Koha::Exceptions::Metadata::Invalid, so unrecoverable records died with a missing-method error instead of returning a proper error. Recoverable records never reached that branch, so the invalid_metadata header was never set and the advanced cataloguing editor no longer warned about encoding issues. This change drops the record_strip_nonxml call and returns a 500 with an XML error body for unrecoverable records. The invalid_metadata header is now set from $biblio->metadata->object_messages, as Koha::OAI::Server::Repository->get_biblio_marcxml does. A new regression test, t/db_dependent/svc/bib.t, covers valid, recoverable, unrecoverable and unknown records. To test: 1. Apply the patch. 2. Create a record and store MARCXML with a control character (chr(31)) in a subfield directly in biblio_metadata. 3. Request /cgi-bin/koha/svc/bib/<biblionumber>. Confirm the response carries "Invalid-metadata: 1" and the repaired record. 4. Open the record in the advanced cataloguing editor and confirm the "Record had encoding issues" alert is shown. 5. Store truncated XML in biblio_metadata and request the same URL. Confirm a 500 with an XML error body, not a missing-method error. 6. Run: prove t/db_dependent/svc/bib.t Sponsored-by: OpenFifth Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org