Bugzilla – Attachment 163995 Details for
Bug 36421
Better logging of 500 errors in V1/Auth.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36421: Make sure pre-controller errors are correctly logged
Bug-36421-Make-sure-pre-controller-errors-are-corr.patch (text/plain), 2.80 KB, created by
Kyle M Hall (khall)
on 2024-03-27 12:42:18 UTC
(
hide
)
Description:
Bug 36421: Make sure pre-controller errors are correctly logged
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-03-27 12:42:18 UTC
Size:
2.80 KB
patch
obsolete
>From 462cff00dca2ef38ffb984e9c0bb99ce752800ef Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 27 Mar 2024 12:29:31 +0000 >Subject: [PATCH] Bug 36421: Make sure pre-controller errors are correctly > logged > >If something explodes in Koha::REST::V1::Auth chances are that no logging will happen. > >This patch makes sure they are! > >To test: >1. Make sure you do NOT have 36420 on your tree >2. Make sure you are looking at the logs: > $ ktd --shell > k$ koha-plack --restart kohadev; tail -f /var/log/koha/kohadev/*.log >3. Use Postman or similar for hitting some known endpoint. Use > the user's cardnumber instead of the userid. On a default KTD launch, the > generated user's cardnumber is '42'. > GET /patrons >=> FAIL: You get a 500 error (expected, fixed on 36420) but no useful logging found. >4. Apply this patch >5. Ctrl+c on the logs and re-run the command >6. Repeat 3 >=> SUCCESS: You get a 500, but you also get the exception information logged! >7. Sign off :-D > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/REST/Plugin/Exceptions.pm | 7 +++---- > Koha/REST/V1/Auth.pm | 10 ++-------- > 2 files changed, 5 insertions(+), 12 deletions(-) > >diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm >index fd28d67e7f6..3bf60c12311 100644 >--- a/Koha/REST/Plugin/Exceptions.pm >+++ b/Koha/REST/Plugin/Exceptions.pm >@@ -71,10 +71,9 @@ sub register { > $c->app->log->error( "$message" ); > > $c->render( >- status => 500, >- openapi => { >- error => >- "Something went wrong, check Koha logs for details.", >+ status => 500, >+ json => { >+ error => "Something went wrong, check Koha logs for details.", > error_code => 'internal_server_error', > } > ); >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index 948bed689bd..e0937e7a2a2 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -95,10 +95,7 @@ sub under { > > } catch { > unless (blessed($_)) { >- return $c->render( >- status => 500, >- json => { error => 'Something went wrong, check the logs.' } >- ); >+ $c->unhandled_exception($_); > } > if ($_->isa('Koha::Exceptions::UnderMaintenance')) { > return $c->render(status => 503, json => { error => $_->error }); >@@ -128,10 +125,7 @@ sub under { > return $c->render(status => 500, json => { error => $_->error }); > } > else { >- return $c->render( >- status => 500, >- json => { error => 'Something went wrong, check the logs.' } >- ); >+ $c->unhandled_exception($_); > } > }; > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36421
:
163856
|
163994
|
163995
|
164117