Bug 41944 - Error 500 on non-existent ILL request (op=illview)
Summary: Error 500 on non-existent ILL request (op=illview)
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: ILL (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-02-26 12:09 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2026-02-28 21:50 UTC (History)
5 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes error 500 and stack trace messages being shown when attempting to access a non-existent ILL request in the staff interface. Now, if no request is found, the standard 404 page not found error page is shown.
Version(s) released in:
Circulation function:


Attachments
Bug 41944: Fix template error for non-existent ILL requests (2.14 KB, patch)
2026-02-26 12:29 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 41944: Fix template error for non-existent ILL requests (2.17 KB, patch)
2026-02-28 21:44 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2026-02-26 12:09:43 UTC
It should be returning the usual 404, but is no checking it and throwing template errors instead.

To reproduce:
1. Have KTD launched with an ILL backend loaded:
   $ ktd --proxy --name rapido --single-plugin ~/git/koha-plugins/rapido-ill up -d
   $ ktd --shell
  k$ cd /kohadevbox/plugins/rapido-ill/scripts
  k$ perl bootstrap_rapido_testing.pl
  k$ restart_all
2. Log into the instance at `http://rapido-admin.localhost`
3. Point your browser to a [non-existent ILL request](http://rapido-intra.localhost/cgi-bin/koha/ill/ill-requests.pl?op=illview&illrequest_id=1000)
=> FAIL: Boo, template errors and stacktrace

Note: In production, the you get a 500 error and the template errors show up in the logs.
Comment 1 Tomás Cohen Arazi (tcohen) 2026-02-26 12:29:02 UTC
Created attachment 193981 [details] [review]
Bug 41944: Fix template error for non-existent ILL requests

This patch fixes a template error that occurred when attempting to view
a non-existent ILL request in the staff interface. Previously, navigating
to ill-requests.pl with an invalid illrequest_id would result in a 500
error and a stacktrace.

This change introduces a check for the existence of the ILL request
immediately after retrieval. If no request is found, the script now
redirects to the standard 404 error page, providing a graceful exit
and preventing internal errors.

Test plan:
1. Ensure KTD is launched with Rapido ILL plugin and bootstrapped (do NOT apply this patch yet):
   $ ktd --proxy --name rapido --single-plugin ~/git/koha-plugins/rapido-ill up -d
   $ ktd --shell
  k$ cd /kohadevbox/plugins/rapido-ill/scripts
  k$ perl bootstrap_rapido_testing.pl
  k$ restart_all
2. Log into the staff interface at http://rapido-intra.localhost.
3. Point your browser to a non-existent ILL request, e.g., http://rapido-intra.localhost/cgi-bin/koha/ill/ill-requests.pl?op=illview&illrequest_id=1000
=> FAIL: Template errors and a stacktrace are displayed, or a 500 error in production logs.
4. Apply this patch.
5. Repeat step 3.
=> SUCCESS: The browser redirects to a 404 Not Found page, and no template errors or stacktraces are displayed.
6. Sign off :-D
Comment 2 David Nind 2026-02-28 21:44:03 UTC
Created attachment 194201 [details] [review]
Bug 41944: Fix template error for non-existent ILL requests

This patch fixes a template error that occurred when attempting to view
a non-existent ILL request in the staff interface. Previously, navigating
to ill-requests.pl with an invalid illrequest_id would result in a 500
error and a stacktrace.

This change introduces a check for the existence of the ILL request
immediately after retrieval. If no request is found, the script now
redirects to the standard 404 error page, providing a graceful exit
and preventing internal errors.

Test plan:
1. Ensure KTD is launched with Rapido ILL plugin and bootstrapped (do NOT apply this patch yet):
   $ ktd --proxy --name rapido --single-plugin ~/git/koha-plugins/rapido-ill up -d
   $ ktd --shell
  k$ cd /kohadevbox/plugins/rapido-ill/scripts
  k$ perl bootstrap_rapido_testing.pl
  k$ restart_all
2. Log into the staff interface at http://rapido-intra.localhost.
3. Point your browser to a non-existent ILL request, e.g., http://rapido-intra.localhost/cgi-bin/koha/ill/ill-requests.pl?op=illview&illrequest_id=1000
=> FAIL: Template errors and a stacktrace are displayed, or a 500 error in production logs.
4. Apply this patch.
5. Repeat step 3.
=> SUCCESS: The browser redirects to a 404 Not Found page, and no template errors or stacktraces are displayed.
6. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2026-02-28 21:50:19 UTC
Testing notes (using KTD):
1. Enable the ILL module (ILLModule system preference).
2. Attempt to view a non-existent ILL request:
   STAFF-INTERFACE-URL/cgi-bin/koha/ill/ill-requests.pl?op=illview&illrequest_id=1000
3. Stack trace error: 
   Template process failed: file error - : not found at /kohadevbox/koha/C4/Templates.pm line 146