[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
Mon Mar 18 16:53:58 CET 2024


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35129

--- Comment #5 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 163343
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163343&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>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list