Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Return 404 in AMQP management queue purge for non-existing queue (backport #13146) #13148

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deps/rabbit/src/rabbit_amqp_management.erl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ handle_http_req(<<"DELETE">>,
[rabbit_misc:rs(QName)])
end
end)
catch exit:#amqp_error{explanation = Explanation} ->
catch exit:#amqp_error{name = not_found, explanation = Explanation} ->
throw(<<"404">>, Explanation, []);
exit:#amqp_error{explanation = Explanation} ->
throw(<<"400">>, Explanation, [])
end;

Expand Down
13 changes: 13 additions & 0 deletions deps/rabbitmq_amqp_client/test/management_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ groups() ->
unbind_bad_binding_path_segment,
exclusive_queue,
purge_stream,
purge_non_existing_queue_should_return_not_found,
pipeline,
multiple_link_pairs,
link_attach_order,
Expand Down Expand Up @@ -778,6 +779,18 @@ purge_stream(Config) ->
{ok, #{}} = rabbitmq_amqp_client:delete_queue(LinkPair, QName),
ok = cleanup(Init).

purge_non_existing_queue_should_return_not_found(Config) ->
Init = {_, LinkPair} = init(Config),
QName = atom_to_binary(?FUNCTION_NAME),

{error, Resp} = rabbitmq_amqp_client:purge_queue(LinkPair, QName),
?assertMatch(#{subject := <<"404">>}, amqp10_msg:properties(Resp)),
#'v1_0.amqp_value'{content = {utf8, Reason}} = amqp10_msg:body(Resp),
?assertEqual(<<"no queue '", QName/binary, "' in vhost '/'">>,
Reason),

ok = cleanup(Init).

queue_topology(Config) ->
NodeNames = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
Nodes = [N0, N1, N2] = lists:map(fun erlang:atom_to_binary/1, NodeNames),
Expand Down
Loading