Bugzilla – Attachment 172008 Details for
Bug 37963
Improve error handling and testing of ERM eUsage SUSHI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37963: Case 1 - Return if sushi_errors even if response code >= 400
Bug-37963-Case-1---Return-if-sushierrors-even-if-r.patch (text/plain), 2.56 KB, created by
Nick Clemens (kidclamp)
on 2024-09-26 18:37:59 UTC
(
hide
)
Description:
Bug 37963: Case 1 - Return if sushi_errors even if response code >= 400
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-09-26 18:37:59 UTC
Size:
2.56 KB
patch
obsolete
>From 7c0f3857dac5f91adad3fd647b14b6d482f9df36 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 19 Sep 2024 13:39:07 +0000 >Subject: [PATCH] Bug 37963: Case 1 - Return if sushi_errors even if response > code >= 400 > >This ensures that SUSHI errors, if present, are shown on the UI even if >response->code >= 400. >This means that if, for example, SUSHI provider returns 401 with SUSHI >error like so: >{"Code": 2020, "Severity": "Error", "Message": "API Key Invalid"} > >Then, the 'API Key Invalid' will be shown to the user, without having to >check logs. > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/ERM/EUsage/UsageDataProvider.pm | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > >diff --git a/Koha/ERM/EUsage/UsageDataProvider.pm b/Koha/ERM/EUsage/UsageDataProvider.pm >index e85ee58ce8c..716610052da 100644 >--- a/Koha/ERM/EUsage/UsageDataProvider.pm >+++ b/Koha/ERM/EUsage/UsageDataProvider.pm >@@ -180,8 +180,11 @@ sub harvest_sushi { > $ua->agent( 'Koha/' . Koha::version() ); > my $response = $ua->simple_request($request); > >+ my $result = decode_json( $response->decoded_content ); >+ > if ( $response->code >= 400 ) { >- my $result = decode_json( $response->decoded_content ); >+ >+ return if $self->_sushi_errors($result); > > my $message; > if ( ref($result) eq 'ARRAY' ) { >@@ -199,7 +202,6 @@ sub harvest_sushi { > } > } > >- #TODO: May want to add a job error message here? > warn sprintf "ERROR - SUSHI service %s returned %s - %s\n", $url, > $response->code, $message; > if ( $response->code == 404 ) { >@@ -208,7 +210,6 @@ sub harvest_sushi { > Koha::Exceptions::Authorization::Unauthorized->throw($message); > } else { > >- #TODO: May want to add a job error message here? > die sprintf "ERROR requesting SUSHI service\n%s\ncode %s: %s\n", > $url, $response->code, > $message; >@@ -217,12 +218,10 @@ sub harvest_sushi { > return; > } > >- my $decoded_response = decode_json( $response->decoded_content ); >- >- return if $self->_sushi_errors($decoded_response); >+ return if $self->_sushi_errors($result); > > # Parse the SUSHI response >- my $sushi_counter = Koha::ERM::EUsage::SushiCounter->new( { response => $decoded_response } ); >+ my $sushi_counter = Koha::ERM::EUsage::SushiCounter->new( { response => $result } ); > my $counter_file = $sushi_counter->get_COUNTER_from_SUSHI; > > return if $self->_counter_file_size_too_large($counter_file); >-- >2.39.5
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 37963
:
171769
|
171770
|
171771
|
171772
|
171887
|
171888
|
171889
|
171890
|
172007
| 172008 |
172009
|
172010
|
172011