[Bug 44307] New: /checkouts?checked_in=1 errors when checkout_date or date_due is null
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 Bug ID: 44307 Summary: /checkouts?checked_in=1 errors when checkout_date or date_due is null Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Circulation Assignee: koha-bugs@lists.koha-community.org Reporter: alexbuckley@catalyst.net.nz QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle@bywatersolutions.com Target Milestone: --- In the Koha database schema the old_issues.issuedate, and old_issues.date_due, database fields have a default value of NULL. However, when there are old_issues.issuedate, or old_issues.date_due, fields of NULL then the /checkouts?checked_in=1 endpoint errors with: { message: 'Expected string - got null" path: "/body/0/checkout_date" } or { message: 'Expected string - got null" path: "/body/0/due_date" } --- To recreate: 1. Checkout an item to a patron and check it back in. 2. Do a call to your instance (may need to turn on api basic auth and just use your credentials), see that you get a result. Note down the checkout_id. 3. Update that historic checkout (substituting the checkout_id from above as the issue_id) and restart services: update old_issues set issuedate = NULL where issue_id=<>; restart_all 4. Send the call again, you'll get a error message at the bottom of the comment: {ktdurl}/api/v1/checkouts?checked_in=true&_per_page=5000&_page=1&_order_by=checkout_date { "errors": [ { "message": "Expected string - got null.", "path": "/body/0/checkout_date" }, 5. Run reset_all then repeat steps 1-4 but set old_issues.date_due to NULL and confirm that also throws an API error. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |alexbuckley@catalyst.net.nz |ity.org | Status|NEW |ASSIGNED -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 --- Comment #1 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Created attachment 212673 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212673&action=edit Bug 44307: Update API to allow for null checkout_date or date_due to be returned when listing checkouts The Koha database schema allows default null values in old_issues.issuedate, and old_issues.date_due, database fields. However, where null values are present, in those database fields then an api call to {url}/api/v1/checkouts?checked_in=true will result in an error. This patch updates the api to allow null values to be returned for those two database fields. To test: Before applying the patch: 1. In Administration->System preference enable the RESTBasicAuth system preference. 2. Checkout an item to a patron 3. Check the item back in 4. In your brower go to {sandbox/ktdurl}/api/v1/checkouts?checked_in=1 5. Observe there is an checkout_date, and due_date, in the JSON response. Also, note down the checkout_id 6. Set both the issuedate, and date_due, to NULL: update old_issues set issuedate = NULL and date_due = NULL where issue_id=<checkout_id from #5>; 7. Repeat step 4 8. Observe an error because "null" values were returned 9. Apply patch Sandbox: In sandbox management Actions->Apply patches Once complete Actions->Build CSS and JS Actions->Restart services KTD: ktd --shell git bz apply 44307 yarn build restart_all 10. Repeat step 4 11. Observe the checkout loads, but now has null checkout_date and due_date values. 12. Sign off On KTD can also run the script: qa to run tests. Sponsored-by: Horowhenua District Council, New Zealand -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=41889 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Sponsorship status|--- |Sponsored Status|Needs Signoff |Signed Off Comma delimited| |Horowhenua District list of Sponsors| |Council, New Zealand -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #212673|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 --- Comment #2 from David Nind <david@davidnind.com> --- Created attachment 212679 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212679&action=edit Bug 44307: Update API to allow for null checkout_date or date_due to be returned when listing checkouts The Koha database schema allows default null values in old_issues.issuedate, and old_issues.date_due, database fields. However, where null values are present, in those database fields then an api call to {url}/api/v1/checkouts?checked_in=true will result in an error. This patch updates the api to allow null values to be returned for those two database fields. To test: Before applying the patch: 1. In Administration->System preference enable the RESTBasicAuth system preference. 2. Checkout an item to a patron 3. Check the item back in 4. In your brower go to {sandbox/ktdurl}/api/v1/checkouts?checked_in=1 5. Observe there is an checkout_date, and due_date, in the JSON response. Also, note down the checkout_id 6. Set both the issuedate, and date_due, to NULL: update old_issues set issuedate = NULL and date_due = NULL where issue_id=<checkout_id from #5>; 7. Repeat step 4 8. Observe an error because "null" values were returned 9. Apply patch Sandbox: In sandbox management Actions->Apply patches Once complete Actions->Build CSS and JS Actions->Restart services KTD: ktd --shell git bz apply 44307 yarn build restart_all 10. Repeat step 4 11. Observe the checkout loads, but now has null checkout_date and due_date values. 12. Sign off On KTD can also run the script: qa to run tests. Sponsored-by: Horowhenua District Council, New Zealand Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44307 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #3 from David Nind <david@davidnind.com> --- Testing notes (using KTD with MariaDB 11.8.9 - the default) 1. The SQL in step 6, didn't update date_due field in the database to null for me (it did for the checkout_date). 2. I used this SQL instead: update old_issues set issuedate = NULL, date_due = NULL where issue_id=1; 3. Then checkout_date and due_date returned as null: [ { "auto_renew": false, "auto_renew_error": null, "booking_id": null, "checkin_date": "2026-11-25T08:43:21+00:00", "checkin_library_id": "CPL", "checkout_date": null, "checkout_id": 1, "due_date": null, "issuer_id": null, "item_id": 578, "last_renewed_date": null, "library_id": "CPL", "note": null, "note_date": null, "note_seen": false, "onsite_checkout": false, "patron_id": 49, "renewals_count": 0, "timestamp": "2026-11-25T08:43:45+00:00", "unseen_renewals": 0 } ] -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org