Bug 40555

Summary: Items with empty itemtype causes Preservation module to crash
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: CirculationAssignee: Bugs List <koha-bugs>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, jonathan.druart, kyle, pedro.amorim
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: Bookings
Attachments: Bug 40555: Consider possibility of item not having itemtype on effective_bookable

Description Pedro Amorim 2025-07-30 14:26:41 UTC
We've hit this recently on our demo installation, but I believe we've stumbled upon this in the past in different parts of Koha that may interact with Items (and Bookings, by extension).
Comment 1 Pedro Amorim 2025-07-30 14:32:02 UTC
The error log message is the following:

GET /api/v1/preservation/waiting-list/items: unhandled exception (Mojo::Exception)<<Can't call method "bookable" on an undefined value at /usr/share/koha/lib/Koha/Item.pm line 1929.>>

Produced when accessing:

<staff_url>/cgi-bin/koha/preservation/waiting-list

With one or more (?) items without an itemtype (or itype, depending on preference?) More analysis required.
Comment 2 Pedro Amorim 2025-07-30 14:34:20 UTC
Created attachment 184897 [details] [review]
Bug 40555: Consider possibility of item not having itemtype on effective_bookable
Comment 3 Jonathan Druart 2025-07-31 09:43:16 UTC
IMO This is invalid. We have discussed on bug 33166 (and others) and decided that we should not deal with corrupted data.

The bug here is to have the column null at the DB level.