[Koha-bugs] [Bug 35129] REST API: _per_page=0 crashes on Illegal division by zero
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Mar 21 16:46:32 CET 2024
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35129
Laura Escamilla <Laura.escamilla at bywatersolutions.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #163343|0 |1
is obsolete| |
--- Comment #7 from Laura Escamilla <Laura.escamilla at bywatersolutions.com> ---
Created attachment 163638
-->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163638&action=edit
Bug 35129: Return 400 if _per_page=0 passed
This patch adds a safe guard for when consumers pass _per_page=0 to
endpoints. This condition is checked for on a centralized place and
avoid reaching the controller in such scenarios that would provoke a
division by zero exception.
To test:
1. Apply the regression tests patch
2. Run:
$ ktd --shell
k$ prove t/db_dependent/api/v1/pagination.t
=> FAIL: We expect a 400, but get a 500 instead
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass! No more explosions for this!
5. Sign off :-D
Signed-off-by: Tomas Cohen Arazi <tomascohen at theke.io>
Signed-off-by: Laura Escamilla <laura.escamilla at bywatersolutions.com>
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list