From 7144c62c272dd2b14e956a55ef2244ed55caa784 Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Fri, 14 Jun 2024 21:44:14 +0000 Subject: [PATCH] Bug 37018: (follow-up) throw a 500 error when an invalid query is found --- Koha/REST/Plugin/Query.pm | 4 ---- t/Koha/REST/Plugin/Query.t | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm index becc5419ef..fd0b17b0c4 100644 --- a/Koha/REST/Plugin/Query.pm +++ b/Koha/REST/Plugin/Query.pm @@ -203,10 +203,6 @@ Validate operators in the passed query. _validate_query( $args->{filtered_params} ); } catch { if ( blessed $_ && $_->isa('Koha::Exceptions::BadParameter') ) { - $c->render( - status => 400, - json => { error => $_->error } - ); Koha::Exceptions::BadParameter->throw( $_->error ); } }; diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t index 55385ac237..75a3bac7a7 100755 --- a/t/Koha/REST/Plugin/Query.t +++ b/t/Koha/REST/Plugin/Query.t @@ -218,7 +218,7 @@ get '/dbic_validate_operators' => sub { } catch { $c->render( - status => 400, + status => 500, json => { error => "$_" } ); }; @@ -689,7 +689,7 @@ subtest 'dbic_validate_operators' => sub { # Invalid queries $q = [ { "-and" => [ [ { "biblio_id" => { "like(sleep(1/100000))or" => "%a%" } } ] ] } ]; $t->get_ok( '/dbic_validate_operators' => json => { q => $q } ) - ->status_is(400) + ->status_is(500) ->json_is( '/error' => qq{Exception 'Koha::Exceptions::BadParameter' thrown 'Invalid operator in query: like(sleep(1/100000))or'\n} ); -- 2.34.1