Bug 32638 - No detailed messages provided in UI when MARC import fails due to bad item data
Summary: No detailed messages provided in UI when MARC import fails due to bad item data
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: MARC Bibliographic record staging/import (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
: 39621 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-01-16 04:32 UTC by David Cook
Modified: 2025-04-18 15:13 UTC (History)
6 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2023-01-16 04:32:49 UTC
In the past, if you had a "coded_location_qualifier" that was too long, the whole MARC import would bust (see bug 30739).

That's no longer the case anymore. However, if the item has a "coded_location_qualifier" like "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789", it will now just be ignored without any more information shown on the Web UI or in the worker logs. 

You wouldn't be able to troubleshoot this issue without writing your own code changes to Koha...
Comment 1 David Cook 2023-05-18 03:17:00 UTC
Bumped into this issue again today when I was trying to import a record that contained an item with a barcode that already existed in Koha.
Comment 2 David Cook 2023-05-18 03:23:55 UTC
I see in C4::ImportBatch::_batchCommitItems that duplicate barcode is the only error that will increment the items errored count...
Comment 3 David Cook 2023-05-18 03:26:38 UTC
Interestingly if the barcode is too long then the whole import fails and I see the following in worker-output.log, so that's something...:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data too long for column 'barcode' at row 1 at /kohadevbox/koha/Koha/Object.pm line 170
Comment 4 David Cook 2023-05-18 03:29:00 UTC
Looks like the coded location qualifier will cause the whole import to fail as well now, so that's good.

You can see this in the worker-output.log:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data too long for column 'coded_location_qualifier' at row 1 at /kohadevbox/koha/Koha/Object.pm line 170

It could be good to add something to the Web UI to ask people to consult their sysadmin so they can check the logs for more specifics...

--

And maybe the duplicate barcode could be hinted at more although given the code flow I can see how that would be very difficult (without throwing a fatal error to stop the whole import)
Comment 5 David Cook 2025-04-14 01:15:53 UTC
*** Bug 39621 has been marked as a duplicate of this bug. ***
Comment 6 David Cook 2025-04-14 01:16:36 UTC
Here's the error when the item has a branchcode that doesn't exist in Koha:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`items`, CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFER
ENCES `branches` (`branchcode`) ON UPDATE CASCADE) at /kohadevbox/koha/Koha/Object.pm line 174
Broken FK constraint at /kohadevbox/koha/Koha/BackgroundJob/MARCImportCommitBatch.pm line 94.
Comment 7 Andrew Fuerste-Henry 2025-04-17 19:29:39 UTC
+1, this is a pain point for users as they're given no indication of the cause of the import failure. The import_records and import_items tables already have import_error fields that could hold these values.
Comment 8 Esther Melander 2025-04-18 15:13:42 UTC
This bug pairs nicely with Bug 36600 Add ability to print or export an import report.