Merge pull request #9678 from kjellwinblad/kjell/fix/jira/EMQX-8648
fix: no feedback when deleting non-existing configuration
This commit is contained in:
commit
692c1f0d1b
|
@ -328,6 +328,7 @@ schema("/bridges/:id") ->
|
|||
responses => #{
|
||||
204 => <<"Bridge deleted">>,
|
||||
400 => error_schema(['INVALID_ID'], "Update bridge failed"),
|
||||
404 => error_schema('NOT_FOUND', "Bridge not found"),
|
||||
403 => error_schema('FORBIDDEN_REQUEST', "Forbidden operation"),
|
||||
503 => error_schema('SERVICE_UNAVAILABLE', "Service unavailable")
|
||||
}
|
||||
|
@ -433,6 +434,8 @@ schema("/nodes/:node/bridges/:id/operation/:operation") ->
|
|||
end,
|
||||
?TRY_PARSE_ID(
|
||||
Id,
|
||||
case emqx_bridge:lookup(BridgeType, BridgeName) of
|
||||
{ok, _} ->
|
||||
case emqx_bridge:check_deps_and_remove(BridgeType, BridgeName, AlsoDeleteActs) of
|
||||
{ok, _} ->
|
||||
204;
|
||||
|
@ -446,6 +449,9 @@ schema("/nodes/:node/bridges/:id/operation/:operation") ->
|
|||
{503, error_msg('SERVICE_UNAVAILABLE', <<"request timeout">>)};
|
||||
{error, Reason} ->
|
||||
{500, error_msg('INTERNAL_ERROR', Reason)}
|
||||
end;
|
||||
{error, not_found} ->
|
||||
{404, error_msg('NOT_FOUND', <<"Bridge not found">>)}
|
||||
end
|
||||
).
|
||||
|
||||
|
|
|
@ -303,6 +303,15 @@ t_http_crud_apis(Config) ->
|
|||
},
|
||||
jsx:decode(ErrMsg2)
|
||||
),
|
||||
%% Deleting a non-existing bridge should result in an error
|
||||
{ok, 404, ErrMsg3} = request(delete, uri(["bridges", BridgeID]), []),
|
||||
?assertMatch(
|
||||
#{
|
||||
<<"code">> := _,
|
||||
<<"message">> := <<"Bridge not found">>
|
||||
},
|
||||
jsx:decode(ErrMsg3)
|
||||
),
|
||||
ok.
|
||||
|
||||
t_http_bridges_local_topic(Config) ->
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
When deleting a non-existing bridge the server gave a success response. This has been fixed so that the server instead gives an error response when the user attempts to delete a non-existing bridge.
|
|
@ -0,0 +1 @@
|
|||
修复了当通过 API 删除一个不存在的桥接时,服务器会返回操作成功的问题,现在将会返回操作失败的信息。
|
Loading…
Reference in New Issue