Bug 40697

Summary: Failures on batch record import because of fkconstraint should report in job report
Product: Koha Reporter: Lisette Scheer <lisette>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Current display in staff interface

Description Lisette Scheer 2025-08-22 18:36:11 UTC
Created attachment 185722 [details]
Current display in staff interface

If a import fails because of an FK_Constraint issue, there is no helpful information in the interface.

It would be very helpful for users if it show that, for example, the branch wasn't valid. 
I've attached a screenshot of what it looks like in the interface.

Example in worker-output.log:

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`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE) at /usr/share/koha/lib/Koha/Object.pm line 172
Broken FK constraint at /usr/share/koha/lib/Koha/BackgroundJob/MARCImportCommitBatch.pm line 90.
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`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE) at /usr/share/koha/lib/Koha/Object.pm line 172
Broken FK constraint at /usr/share/koha/lib/Koha/BackgroundJob/MARCImportCommitBatch.pm line 90.
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`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE) at /usr/share/koha/lib/Koha/Object.pm line 172
Broken FK constraint at /usr/share/koha/lib/Koha/BackgroundJob/MARCImportCommitBatch.pm line 90.