Merge pull request #11256 from thalesmg/bridge-api-ecpool-400-errors-20230712-r51

fix(bridge_api): return 400 for all ecpool start errors
This commit is contained in:
Thales Macedo Garitezi 2023-07-13 10:05:07 -03:00 committed by GitHub
commit 924ed06760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -983,15 +983,10 @@ call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
%% still on an older bpapi version that doesn't support it.
maybe_try_restart(NodeOrAll, OperFunc, Args);
{error, timeout} ->
?SERVICE_UNAVAILABLE(<<"Request timeout">>);
?BAD_REQUEST(<<"Request timeout">>);
{error, {start_pool_failed, Name, Reason}} ->
Msg = bin(io_lib:format("Failed to start ~p pool for reason ~p", [Name, Reason])),
case Reason of
nxdomain ->
?BAD_REQUEST(Msg);
_ ->
?SERVICE_UNAVAILABLE(Msg)
end;
?BAD_REQUEST(Msg);
{error, not_found} ->
BridgeId = emqx_bridge_resource:bridge_id(BridgeType, BridgeName),
?SLOG(warning, #{

View File

@ -834,7 +834,8 @@ do_start_stop_bridges(Type, Config) ->
),
BadBridgeID = emqx_bridge_resource:bridge_id(?BRIDGE_TYPE_MQTT, BadName),
?assertMatch(
{ok, SC, _} when SC == 500 orelse SC == 503,
%% request from product: return 400 on such errors
{ok, SC, _} when SC == 500 orelse SC == 400,
request(post, {operation, Type, start, BadBridgeID}, Config)
),
ok = gen_tcp:close(Sock),