Merge pull request #11268 from thalesmg/fix-unhealthy-target-api-return

fix(resource): don't destruct error tuple
This commit is contained in:
Thales Macedo Garitezi 2023-07-14 09:14:39 -03:00 committed by GitHub
commit faa851d51a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -546,7 +546,12 @@ schema("/bridges_probe") ->
?NO_CONTENT; ?NO_CONTENT;
{error, #{kind := validation_error} = Reason} -> {error, #{kind := validation_error} = Reason} ->
?BAD_REQUEST('TEST_FAILED', map_to_json(Reason)); ?BAD_REQUEST('TEST_FAILED', map_to_json(Reason));
{error, Reason} when not is_tuple(Reason); element(1, Reason) =/= 'exit' -> {error, Reason0} when not is_tuple(Reason0); element(1, Reason0) =/= 'exit' ->
Reason =
case Reason0 of
{unhealthy_target, Message} -> Message;
_ -> Reason0
end,
?BAD_REQUEST('TEST_FAILED', Reason) ?BAD_REQUEST('TEST_FAILED', Reason)
end; end;
BadRequest -> BadRequest ->

View File

@ -1211,7 +1211,7 @@ t_nonexistent_topic(Config) ->
emqx_resource_manager:health_check(ResourceId) emqx_resource_manager:health_check(ResourceId)
), ),
?assertMatch( ?assertMatch(
{ok, _Group, #{error := "GCP PubSub topics are invalid" ++ _}}, {ok, _Group, #{error := {unhealthy_target, "GCP PubSub topics are invalid" ++ _}}},
emqx_resource_manager:lookup_cached(ResourceId) emqx_resource_manager:lookup_cached(ResourceId)
), ),
%% now create the topic and restart the bridge %% now create the topic and restart the bridge

View File

@ -642,7 +642,6 @@ status_to_error(_) ->
{error, undefined}. {error, undefined}.
%% Compatibility %% Compatibility
external_error({error, {unhealthy_target, Message}}) -> Message;
external_error({error, Reason}) -> Reason; external_error({error, Reason}) -> Reason;
external_error(Other) -> Other. external_error(Other) -> Other.