fix(resource): don't destruct error tuple

Otherwise, `emqx_resource:query` won't correctly deem the resource to
be unhealthy when there's an extra message.
This commit is contained in:
Thales Macedo Garitezi 2023-07-13 16:00:25 -03:00
parent 0dff428efb
commit 01b143c5ad
3 changed files with 7 additions and 3 deletions

View File

@ -546,7 +546,12 @@ schema("/bridges_probe") ->
?NO_CONTENT;
{error, #{kind := validation_error} = 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)
end;
BadRequest ->

View File

@ -1211,7 +1211,7 @@ t_nonexistent_topic(Config) ->
emqx_resource_manager:health_check(ResourceId)
),
?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)
),
%% now create the topic and restart the bridge

View File

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