From 93bae7faf85d4c7c66f510764a731275d8ac0d58 Mon Sep 17 00:00:00 2001 From: Simon Unge Date: Thu, 29 Aug 2024 17:58:55 +0000 Subject: [PATCH] Minor fix: GET/HEAD method on non existing shovel crash (cherry picked from commit 16463e72cc8d00a4d1c6af4afe70830f534977cb) --- .../src/rabbit_shovel_mgmt_shovel.erl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/deps/rabbitmq_shovel_management/src/rabbit_shovel_mgmt_shovel.erl b/deps/rabbitmq_shovel_management/src/rabbit_shovel_mgmt_shovel.erl index 9297437029..f41e70d0b8 100644 --- a/deps/rabbitmq_shovel_management/src/rabbit_shovel_mgmt_shovel.erl +++ b/deps/rabbitmq_shovel_management/src/rabbit_shovel_mgmt_shovel.erl @@ -45,17 +45,22 @@ resource_exists(ReqData, Context) -> case name(ReqData) of none -> true; Name -> - %% Deleting or restarting a shovel case get_shovel_node(VHost, Name, ReqData, Context) of undefined -> rabbit_log:error("Shovel with the name '~ts' was not found on virtual host '~ts'. " "It may be failing to connect and report its status.", [Name, VHost]), - case is_restart(ReqData) of - true -> false; - %% this is a deletion attempt, it can continue and idempotently try to - %% delete the shovel - false -> true + case cowboy_req:method(ReqData) of + <<"DELETE">> -> + %% Deleting or restarting a shovel + case is_restart(ReqData) of + true -> false; + %% this is a deletion attempt, it can continue and idempotently try to + %% delete the shovel + false -> true + end; + _ -> + false end; _ -> true