Bug 39358

Summary: Automatically assign itemId for items created with https://api.koha-community.org/api/v1/biblios/{biblio_id}/items
Product: Koha Reporter: Oswald Kaipainen <urho>
Component: REST APIAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: tomascohen
Version: unspecified   
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:

Description Oswald Kaipainen 2025-03-17 12:53:15 UTC
Correct me if I'm wrong but currently creating new items with POST to /biblios/{biblio_id}/items requires item_id. I think it would be more convenient if item_id could be omitted and the handler would assign items using the auto increment value of items table. Then on the response item_id:s would be populated accordingly. 

This would prevent potential conflicts when items are being created from multiple sources. Additionally, it seems that item IDs can be manually entered above 2147483647, causing item creation to lock up until the auto-increment value is manually reset.

So in a nutshell:

1) Allow item_id to be omitted in POST /biblios/{biblio_id}/items requests.
2) If item_id is not provided, the API should let the database assign it via auto-increment.
3) The response should return the created items with their assigned item_id values.
Comment 1 Katrin Fischer 2025-03-17 13:58:20 UTC
This sounds more like a dangeorus bug than anything else. No outside script should be able to assign PK in my opinion. It will mess with the counters?