Bugzilla – Attachment 106650 Details for
Bug 25952
Github search for plugin throwing errors due to API rate limits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25952: Add error-handling to prevent errors from rate limiting
Bug-25952-Add-error-handling-to-prevent-errors-fro.patch (text/plain), 2.49 KB, created by
David Cook
on 2020-07-08 11:05:48 UTC
(
hide
)
Description:
Bug 25952: Add error-handling to prevent errors from rate limiting
Filename:
MIME Type:
Creator:
David Cook
Created:
2020-07-08 11:05:48 UTC
Size:
2.49 KB
patch
obsolete
>From 1a2dd42aafb2138bd54d1f1a196fb5ad01cc4f97 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 8 Jul 2020 11:01:48 +0000 >Subject: [PATCH] Bug 25952: Add error-handling to prevent errors from rate > limiting > >This patch makes sure there is a successful response before trying to decode >the response. > >If you search for "koha-plugin" in the Bywater and Theke repos, >you'll quickly exceed your API rate limit, and you'll stop getting >successful responses. > >To test: >0) Don't apply patch yet >1) Enable plugins >2) Enable plugin_repos >3) Search for koha-plugin a few times >4) Notice how Plack crashes with a visible error in the browser >5) Apply the patch >6) restart_all (in koha-testing-docker) >7) Search for koha-plugin >8) Observe that no search results are returned and there are no errors >in the browser >--- > plugins/plugins-home.pl | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > >diff --git a/plugins/plugins-home.pl b/plugins/plugins-home.pl >index e3335ab4bd..3736367da4 100755 >--- a/plugins/plugins-home.pl >+++ b/plugins/plugins-home.pl >@@ -71,14 +71,18 @@ if ($plugins_enabled) { > foreach my $result ( @{ $response->{items} } ) { > next unless $result->{name} =~ /^koha-plugin-/; > my $releases = $result->{url} . "/releases/latest"; >- my $release = from_json( get($releases) ); >- for my $asset ( @{$release->{assets}} ) { >- if ($asset->{browser_download_url} =~ m/\.kpz$/) { >- $result->{install_name} = $asset->{name}; >- $result->{install_url} = $asset->{browser_download_url}; >+ my $releases_response = get($releases); >+ if ($releases_response){ >+ my $release = from_json( $releases_response ); >+ for my $asset ( @{$release->{assets}} ) { >+ if ($asset->{browser_download_url} =~ m/\.kpz$/) { >+ $result->{install_name} = $asset->{name}; >+ $result->{install_url} = $asset->{browser_download_url}; >+ } > } >+ push( @results, { repo => $r, result => $result } ); > } >- push( @results, { repo => $r, result => $result } ); >+ #FIXME: tell the user that the response failed > } > } > } >-- >2.11.0
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 25952
: 106650