Skip to content

Commit 383ddb1

Browse files
committed
Use different not_found msg for vhosts & resources
Issue #10901
1 parent 0b4fff9 commit 383ddb1

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ content_types_provided(ReqData, Context) ->
3131

3232
resource_exists(ReqData, Context) ->
3333
{case rabbit_mgmt_wm_exchange:exchange(ReqData) of
34-
not_found -> false;
34+
not_found -> raise_not_found(ReqData, Context);
3535
_ -> true
3636
end, ReqData, Context}.
3737

3838
allow_missing_post(ReqData, Context) ->
39-
rabbit_mgmt_util:not_found(
40-
rabbit_data_coercion:to_binary("vhost_not_found"),
41-
ReqData,
42-
Context).
39+
{false, ReqData, Context}.
4340

4441
content_types_accepted(ReqData, Context) ->
4542
{[{'*', accept_content}], ReqData, Context}.
@@ -107,6 +104,18 @@ bad({{coordinator_unavailable, _}, _}, ReqData, Context) ->
107104
is_authorized(ReqData, Context) ->
108105
rabbit_mgmt_util:is_authorized_vhost(ReqData, Context).
109106

107+
raise_not_found(ReqData, Context) ->
108+
ErrorMessage = case rabbit_mgmt_util:vhost(ReqData) of
109+
not_found ->
110+
"vhost_not_found";
111+
_ ->
112+
"exchange_not_found"
113+
end,
114+
rabbit_mgmt_util:not_found(
115+
rabbit_data_coercion:to_binary(ErrorMessage),
116+
ReqData,
117+
Context).
118+
110119
%%--------------------------------------------------------------------
111120

112121
decode(Payload, <<"string">>) -> Payload;

deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_actions.erl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@ allowed_methods(ReqData, Context) ->
2828

2929
resource_exists(ReqData, Context) ->
3030
{case rabbit_mgmt_wm_queue:queue(ReqData) of
31-
not_found -> false;
31+
not_found -> raise_not_found(ReqData, Context);
3232
_ -> true
3333
end, ReqData, Context}.
3434

3535
allow_missing_post(ReqData, Context) ->
36-
rabbit_mgmt_util:not_found(
37-
rabbit_data_coercion:to_binary("vhost_not_found"),
38-
ReqData,
39-
Context).
36+
{false, ReqData, Context}.
4037

4138
content_types_accepted(ReqData, Context) ->
4239
{[{'*', accept_content}], ReqData, Context}.
@@ -58,6 +55,17 @@ do_it(ReqData0, Context) ->
5855
is_authorized(ReqData, Context) ->
5956
rabbit_mgmt_util:is_authorized_admin(ReqData, Context).
6057

58+
raise_not_found(ReqData, Context) ->
59+
ErrorMessage = case rabbit_mgmt_util:vhost(ReqData) of
60+
not_found ->
61+
"vhost_not_found";
62+
_ ->
63+
"queue_not_found"
64+
end,
65+
rabbit_mgmt_util:not_found(
66+
rabbit_data_coercion:to_binary(ErrorMessage),
67+
ReqData,
68+
Context).
6169
%%--------------------------------------------------------------------
6270

6371
action(<<"sync">>, Q, ReqData, Context) when ?is_amqqueue(Q) ->

deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ content_types_provided(ReqData, Context) ->
3131

3232
resource_exists(ReqData, Context) ->
3333
{case rabbit_mgmt_wm_queue:queue(ReqData) of
34-
not_found -> false;
34+
not_found -> raise_not_found(ReqData, Context);
3535
_ -> true
3636
end, ReqData, Context}.
3737

3838
allow_missing_post(ReqData, Context) ->
39-
rabbit_mgmt_util:not_found(
40-
rabbit_data_coercion:to_binary("vhost_not_found"),
41-
ReqData,
42-
Context).
39+
{false, ReqData, Context}.
4340

4441
content_types_accepted(ReqData, Context) ->
4542
{[{'*', accept_content}], ReqData, Context}.
@@ -155,6 +152,17 @@ basic_get(Ch, Q, AckMode, Enc, Trunc) ->
155152
is_authorized(ReqData, Context) ->
156153
rabbit_mgmt_util:is_authorized_vhost(ReqData, Context).
157154

155+
raise_not_found(ReqData, Context) ->
156+
ErrorMessage = case rabbit_mgmt_util:vhost(ReqData) of
157+
not_found ->
158+
"vhost_not_found";
159+
_ ->
160+
"queue_not_found"
161+
end,
162+
rabbit_mgmt_util:not_found(
163+
rabbit_data_coercion:to_binary(ErrorMessage),
164+
ReqData,
165+
Context).
158166
%%--------------------------------------------------------------------
159167

160168
maybe_truncate(Payload, none) -> Payload;

0 commit comments

Comments
 (0)