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 => #{
|
responses => #{
|
||||||
204 => <<"Bridge deleted">>,
|
204 => <<"Bridge deleted">>,
|
||||||
400 => error_schema(['INVALID_ID'], "Update bridge failed"),
|
400 => error_schema(['INVALID_ID'], "Update bridge failed"),
|
||||||
|
404 => error_schema('NOT_FOUND', "Bridge not found"),
|
||||||
403 => error_schema('FORBIDDEN_REQUEST', "Forbidden operation"),
|
403 => error_schema('FORBIDDEN_REQUEST', "Forbidden operation"),
|
||||||
503 => error_schema('SERVICE_UNAVAILABLE', "Service unavailable")
|
503 => error_schema('SERVICE_UNAVAILABLE', "Service unavailable")
|
||||||
}
|
}
|
||||||
|
@ -433,6 +434,8 @@ schema("/nodes/:node/bridges/:id/operation/:operation") ->
|
||||||
end,
|
end,
|
||||||
?TRY_PARSE_ID(
|
?TRY_PARSE_ID(
|
||||||
Id,
|
Id,
|
||||||
|
case emqx_bridge:lookup(BridgeType, BridgeName) of
|
||||||
|
{ok, _} ->
|
||||||
case emqx_bridge:check_deps_and_remove(BridgeType, BridgeName, AlsoDeleteActs) of
|
case emqx_bridge:check_deps_and_remove(BridgeType, BridgeName, AlsoDeleteActs) of
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
204;
|
204;
|
||||||
|
@ -446,6 +449,9 @@ schema("/nodes/:node/bridges/:id/operation/:operation") ->
|
||||||
{503, error_msg('SERVICE_UNAVAILABLE', <<"request timeout">>)};
|
{503, error_msg('SERVICE_UNAVAILABLE', <<"request timeout">>)};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{500, error_msg('INTERNAL_ERROR', Reason)}
|
{500, error_msg('INTERNAL_ERROR', Reason)}
|
||||||
|
end;
|
||||||
|
{error, not_found} ->
|
||||||
|
{404, error_msg('NOT_FOUND', <<"Bridge not found">>)}
|
||||||
end
|
end
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
|
@ -303,6 +303,15 @@ t_http_crud_apis(Config) ->
|
||||||
},
|
},
|
||||||
jsx:decode(ErrMsg2)
|
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.
|
ok.
|
||||||
|
|
||||||
t_http_bridges_local_topic(Config) ->
|
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