[Bug 43028] New: Isolate one undecodable record from aborting a batch import or revert
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Bug ID: 43028 Summary: Isolate one undecodable record from aborting a batch import or revert Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Tools Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Depends on: 35104 Target Milestone: --- Bug 35104 makes Koha::Biblio::Metadata->store() throw Koha::Exceptions::Metadata::Invalid for MARCXML it cannot save. Batch import (C4::ImportBatch::BatchCommitRecords/_batchCommitItems), batch revert (BatchRevertRecords), the corresponding background jobs, the CLI tools built on them (misc/commit_file.pl, misc/migration_tools/bulkmarcimport.pl), and Koha::Import::Record::get_marc_record all needed updating so one bad record doesn't take the rest of the batch down with it. This patch: - Catches the exception per-record in BatchCommitRecords (which already commits per-record) and per-item in _batchCommitItems, flagging the record/item with an 'error' status and message and counting it via a new $num_errored return value, instead of letting it propagate. - Does the same for BatchRevertRecords, which runs as a single whole-batch transaction: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. - Threads the new error counts through Koha::BackgroundJob::MARCImportCommitBatch/RevertBatch's job report, and counts errored records towards job progress so a batch containing them doesn't get stuck showing as still running. - Reports the new counts in misc/commit_file.pl's CLI summary and logs a warning line for records automatically repaired during bulkmarcimport.pl. - Surfaces each errored row's reason as a tooltip on its "Error" status badge in the manage-marc-import listing. - Makes Koha::Import::Record::get_marc_record reuse Koha::Biblio::Metadata::repair_marcxml (bug 35104) instead of its own weaker strip-and-retry, so staged import records get the same recovery (including empty-datafield handling) as the interactive cataloguing form. Depends on bug 35104. Test plan: 1. Apply this patch on top of bug 35104. 2. Stage a MARC file for import (Tools > Stage MARC records for import) containing at least one deliberately malformed record (e.g. a datafield with no subfields, or invalid control characters that cannot be repaired) alongside normal records. 3. From Manage staged records, commit the batch. Confirm: the bad record is flagged with an 'error' status and a tooltip explaining why; every other record in the batch imports successfully; the job report/CLI summary shows a "Number of records with errors" count. 4. Revert the same batch. Confirm one record whose marcxml_old cannot be restored does not prevent the rest of the batch from reverting, and the job report reflects the error count. 5. Run misc/migration_tools/bulkmarcimport.pl from the CLI against a file containing a record with a recoverable fault (e.g. a non-XML character). Confirm a WARNING line is logged for that record and the import otherwise completes normally. 6. prove t/db_dependent/ImportBatch.t t/db_dependent/Koha/BackgroundJob/MARCImportCommitBatch.t 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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201705 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201705&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. -- 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=43028 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201706 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201706&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. -- 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=43028 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201707 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201707&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. -- 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=43028 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201708 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201708&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. -- 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=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #201705|0 |1 is obsolete| | Attachment #201706|0 |1 is obsolete| | Attachment #201707|0 |1 is obsolete| | Attachment #201708|0 |1 is obsolete| | -- 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=43028 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201731 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201731&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> 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=43028 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201732 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201732&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- 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=43028 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201733 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201733&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> 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=43028 --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201734 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201734&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- 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=43028 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. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- 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=43028 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 -- 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=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #201731|0 |1 is obsolete| | Attachment #201732|0 |1 is obsolete| | Attachment #201733|0 |1 is obsolete| | Attachment #201734|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=43028 --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 203273 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203273&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 203274 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203274&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #11 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 203275 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203275&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #12 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 203276 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203276&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |nick@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=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Sponsorship status|--- |Sponsored Comma delimited| |OpenFifth list of Sponsors| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #203273|0 |1 is obsolete| | Attachment #203274|0 |1 is obsolete| | Attachment #203275|0 |1 is obsolete| | Attachment #203276|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=43028 --- Comment #13 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 204740 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=204740&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #14 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 204741 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=204741&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #15 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 204742 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=204742&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #16 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 204743 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=204743&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|35104 |43777 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 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 watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #204740|0 |1 is obsolete| | Attachment #204741|0 |1 is obsolete| | Attachment #204742|0 |1 is obsolete| | Attachment #204743|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=43028 --- Comment #17 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207718 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207718&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #18 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207719 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207719&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #19 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207720 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207720&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #20 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207721 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207721&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|43777 |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 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 watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207718|0 |1 is obsolete| | Attachment #207719|0 |1 is obsolete| | Attachment #207720|0 |1 is obsolete| | Attachment #207721|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=43028 --- Comment #21 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207732 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207732&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #22 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207733 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207733&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #23 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207734 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207734&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #24 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207735 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207735&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207732|0 |1 is obsolete| | Attachment #207733|0 |1 is obsolete| | Attachment #207734|0 |1 is obsolete| | Attachment #207735|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=43028 --- Comment #25 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207781 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207781&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #26 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207782 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207782&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #27 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207783 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207783&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #28 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207784 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207784&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Nick Clemens (kidclamp) <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA --- Comment #29 from Nick Clemens (kidclamp) <nick@bywatersolutions.com> --- I cannot stage records with problems, I suspect that may be a different bug that needs to be filed - I'll attach the file I created I then attempted to import 2 good records overtop records in the catalog that I corrupted - the job failed on a record with a blank 500 field - I cannot revert a partial import - which may be it's own problem - if I import 500 records and 1 fails I now cannot undo that. To recreate: Export record 184,228 Corrupt them: UPDATE biblio_metadata SET metadata = REPLACE(metadata, '<subfield code="a">', CONCAT('<subfield code="a">', CHAR(31))) WHERE biblionumber IN (228) AND format = 'marcxml'; UPDATE biblio_metadata SET metadata = REPLACE(metadata, '</record>', '<datafield tag="500" ind1=" " ind2=" "></datafield></record>') WHERE biblionumber =184; Import, match and overlay -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #30 from Nick Clemens (kidclamp) <nick@bywatersolutions.com> --- Created attachment 209799 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209799&action=edit Records with bad xml -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207781|0 |1 is obsolete| | Attachment #207782|0 |1 is obsolete| | Attachment #207783|0 |1 is obsolete| | Attachment #207784|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=43028 --- Comment #31 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210047 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210047&action=edit Bug 43028: Isolate one undecodable record from aborting a batch import or revert BatchCommitRecords already ran each record in its own transaction; extend that to catch Koha::Exceptions::Metadata::Invalid (bug 35104) per-record instead of letting it propagate, flagging the record with an 'error' status and import_error message and counting it via the new $num_errored return value, rather than aborting records after it in the same batch. _batchCommitItems gets the same per-item treatment for undecodable item MARCXML. BatchRevertRecords runs as a single whole-batch transaction, so the same care is needed in its 'restore' branch too: both the marcxml_old decode step and the ModBiblio/ModAuthority call that follows it are isolated, so one record that can't be restored doesn't roll back every other record already reverted in the same batch. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #32 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210048 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210048&action=edit Bug 43028: Report errored records in the batch import/revert background job summary Thread BatchCommitRecords' new num_errored count and BatchRevertRecords' num_errors through the background job report, and count errored records towards job progress/completion - otherwise a batch containing errored records would never reach its expected progress total and the job would appear stuck at "running". Show the new count in the commit batch report template. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #33 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210049 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210049&action=edit Bug 43028: Reuse Koha::Biblio::Metadata's MARCXML repair in Import::Record get_marc_record() previously reimplemented its own bare strip-and-retry fallback, independent of Koha::Biblio::Metadata's recovery (bug 35104). That meant staged import records didn't benefit from the empty-datafield recovery added alongside the non-XML stripping, and the two implementations could silently drift apart. Use the shared repair_marcxml() instead. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #34 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210050 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210050&action=edit Bug 43028: Show and report undecodable records in remaining batch import tooling - misc/commit_file.pl: report the new num_errored count from BatchCommitRecords in its CLI summary. - misc/migration_tools/bulkmarcimport.pl: log a warning line (and to the logfile, if enabled) for every record automatically repaired during a bulk import, via the same warnings option used elsewhere - consistent with this script's existing warn-to-stderr convention. - tools/batch_records_ajax.pl / manage-marc-import.tt: surface each errored row's import_error as a tooltip on its "Error" status badge in the manage-marc-import listing, instead of just the bare status. Signed-off-by: Baptiste Bayche <baptiste.bayche@inlibro.com> Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> Sponsored-by: OpenFifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43028 --- Comment #35 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210051 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210051&action=edit Bug 43028: Isolate a corrupt record in the catalog when overlaying When a batch overlays an existing record that is itself corrupt in the catalog, the old record was decoded outside of the per-record isolation. A single bad catalog record made BatchCommitRecords die, leaving the whole batch in 'importing' state, where it could neither be completed nor reverted. Read the record being replaced through Koha::Biblio::Metadata->record, which repairs what can be repaired, and report what cannot as an error on that import record only. Any other unexpected exception raised while importing a record is now also reported against that record (and logged), so the remaining records are still imported and the batch ends in 'imported' state. To test: 1. Stage a batch overlaying existing records, then corrupt the catalog records it matches (e.g. blank <datafield tag="500"...></datafield>, a control character in a subfield, or truncated XML). 2. Commit the batch. => Before: the commit dies and the batch stays 'importing'. => After: repairable records are overlaid, unrepairable ones are flagged 'error' with the reason, the batch is 'imported' and can be reverted. 3. prove t/db_dependent/ImportBatch.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=43028 --- Comment #36 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210052 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210052&action=edit Bug 43028: Do not drop or duplicate records when staging a MARCXML file with a bad record RecordsFromMARCXMLFile kept the record variable across iterations, so when a record could not be parsed the previous record was added a second time, and when the first record could not be parsed the loop ended there and every record after it was lost. Read each record in its own scope, report the ones that cannot be parsed, and carry on with the next one. The end of the file is still only a record that is missing without an error, and a parser that keeps failing with the same error stops the loop. To test: 1. Stage a MARCXML file with three records where the second contains a character reference to a control character, e.g. <subfield code="a">Badrecord</subfield> => Before: the first record is staged twice and the error is not tied to any record. => After: the first and third records are staged, and the error is reported. 2. prove t/ImportBatch.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=43028 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off --- Comment #37 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Thanks Nick, your feedback turned up two real problems, now fixed in two follow-up patches (rebased onto current main, signoffs on the existing patches unchanged). 1. Overlaying onto a record that is already corrupt in the catalog: the record being replaced was decoded outside the per-record isolation, so one bad catalog record made the whole commit die and left the batch stuck in 'importing', where it could be neither finished nor reverted. It is now read through Koha::Biblio::Metadata->record (repairing what can be repaired); records that cannot be read are flagged 'error' with the reason, any other unexpected failure is isolated and logged per record, and the batch ends 'imported'. Checked end to end with three corrupted catalog records (blank datafield, control character, truncated XML): 2 overlaid, 1 flagged, batch imported, and revert restored the original titles. 2. Staging a MARCXML file with an unparseable record: RecordsFromMARCXMLFile kept the record across iterations, so the previous record was staged twice, and an unparseable first record dropped all the rest. Each record is now read on its own, errors are reported, and the next record is still read. Note that your control-character file is not well-formed XML, so the parser can only report it and carry on where it can. Both have tests (t/db_dependent/ImportBatch.t, t/ImportBatch.t); koha-qa is clean. Back to Signed Off for QA. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org