fix: keep builtin_console actions not complain args

This commit is contained in:
zhongwencool 2023-09-15 16:38:04 +08:00
parent 6919cd4df0
commit d72348c8ed
3 changed files with 28 additions and 9 deletions

View File

@ -45,11 +45,15 @@
%%--------------------------------------------------------------------
parse_action(#{function := ActionFunc} = Action) ->
{Mod, Func} = parse_action_func(ActionFunc),
#{
mod => Mod,
func => Func,
args => pre_process_args(Mod, Func, maps:get(args, Action, #{}))
}.
Res = #{mod => Mod, func => Func},
%% builtin_action_console don't have args field.
%% Attempting to save args to the console action config could cause validation issues
case Action of
#{args := Args} ->
Res#{args => pre_process_args(Mod, Func, Args)};
_ ->
Res
end.
%%--------------------------------------------------------------------
%% callbacks of emqx_rule_action

View File

@ -2,7 +2,7 @@
{application, emqx_rule_engine, [
{description, "EMQX Rule Engine"},
% strict semver, bump manually!
{vsn, "5.0.25"},
{vsn, "5.0.26"},
{modules, []},
{registered, [emqx_rule_engine_sup, emqx_rule_engine]},
{applications, [kernel, stdlib, rulesql, getopt, emqx_ctl, uuid]},

View File

@ -98,10 +98,25 @@ fields("builtin_action_republish") ->
];
fields("builtin_action_console") ->
[
{function, ?HOCON(console, #{desc => ?DESC("console_function")})}
{function, ?HOCON(console, #{desc => ?DESC("console_function")})},
%% we may support some args for the console action in the future
%, {args, sc(map(), #{desc => "The arguments of the built-in 'console' action",
% default => #{}})}
%% "args" needs to be a reserved/ignored field in the schema
%% to maintain compatibility with rule data that may contain
%% it due to a validation bug in previous versions.
%% The "args" field was not validated by the HOCON schema before 5.2.0,
%% which allowed rules to be created with invalid "args" data.
%% In 5.2.1 the validation was added,
%% so existing rules saved with invalid "args" would now fail validation
%% To maintain backward compatibility for existing rule data that may contain invalid "args",
%% the field needs to be included in the schema even though it is not a valid field.
{args,
?HOCON(map(), #{
deprecated => true,
desc => "The arguments of the built-in 'console' action",
default => #{}
})}
];
fields("user_provided_function") ->
[