Merge pull request #12356 from thalesmg/fix-mqtt-ingress-pub-local-r55-20240119

fix(mqtt_source): don't attempt local publish when legacy config is absent
This commit is contained in:
Thales Macedo Garitezi 2024-01-19 13:06:44 -03:00 committed by GitHub
commit 270eb81f8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -18,6 +18,7 @@
-include_lib("emqx/include/logger.hrl").
-include_lib("emqx/include/emqx_mqtt.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
%% management APIs
-export([
@ -284,9 +285,10 @@ maybe_on_message_received(Msg, {Mod, Func, Args}) ->
maybe_on_message_received(_Msg, undefined) ->
ok.
maybe_publish_local(Msg, Local = #{}, Props) ->
maybe_publish_local(Msg, Local = #{topic := Topic}, Props) when Topic =/= undefined ->
?tp(mqtt_ingress_publish_local, #{msg => Msg, local => Local}),
emqx_broker:publish(to_broker_msg(Msg, Local, Props));
maybe_publish_local(_Msg, undefined, _Props) ->
maybe_publish_local(_Msg, _Local, _Props) ->
ok.
%%

View File

@ -187,7 +187,7 @@ source_examples(Method) ->
#{
parameters => #{
topic => <<"remote/topic">>,
qos => 2
qos => 1
}
}
)

View File

@ -238,6 +238,9 @@ t_receive_via_rule(Config) ->
end,
fun(Trace) ->
?assertEqual([], ?of_kind("action_references_nonexistent_bridges", Trace)),
%% We don't have the hidden, legacy `local' config set, so we shouldn't
%% attempt to publish directly.
?assertEqual([], ?of_kind(mqtt_ingress_publish_local, Trace)),
ok
end
),