Bug 40471 - Long barcodes in "Add item" throw 500 error
Summary: Long barcodes in "Add item" throw 500 error
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-23 00:55 UTC by David Cook
Modified: 2025-07-25 02:58 UTC (History)
1 user (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 2025-07-23 00:55:52 UTC
If you try to enter a very long barcode for an item in the "Add item" screen, you'll get a 500 error and the following in the logs:

[WARN] 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 174

It should be trivial for us to add length limit checks in the HTML and the Perl.
Comment 1 David Cook 2025-07-25 02:58:02 UTC
Owen commented on Mattermost about how the default framework should enforce a maxlength for 952$p, which led me to raise bug 40508 where I've added a patch that does that.

We could add a DB update here to set maxlength to 20 if kohafield = 'items.barcode".

--

Note: While maxlength does prevent new barcodes from being input that are greater than 20 characters, it doesn't prevent you from saving an item that already has a barcode that is longer than that.