Bug 39358 - Automatically assign itemId for items created with https://api.koha-community.org/api/v1/biblios/{biblio_id}/items
Summary: Automatically assign itemId for items created with https://api.koha-community...
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-17 12:53 UTC by Oswald Kaipainen
Modified: 2025-03-17 13: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 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?