Explorar el Código

fix: match decode plugin config map failed case

JimMoen hace 1 año
padre
commit
874bcd9a8b
Se han modificado 1 ficheros con 14 adiciones y 2 borrados
  1. 14 2
      apps/emqx_plugins/src/emqx_plugins.erl

+ 14 - 2
apps/emqx_plugins/src/emqx_plugins.erl

@@ -1235,8 +1235,7 @@ ensure_config_map(NameVsn) ->
         {ok, ConfigJsonMap} ->
             case with_plugin_avsc(NameVsn) of
                 true ->
-                    {ok, AvroValue} = decode_plugin_config_map(NameVsn, ConfigJsonMap),
-                    put_config(NameVsn, ConfigJsonMap, AvroValue);
+                    do_ensure_config_map(NameVsn, ConfigJsonMap);
                 false ->
                     put_config(NameVsn, ConfigJsonMap, ?plugin_without_config_schema)
             end;
@@ -1245,6 +1244,19 @@ ensure_config_map(NameVsn) ->
             ok
     end.
 
+do_ensure_config_map(NameVsn, ConfigJsonMap) ->
+    case decode_plugin_config_map(NameVsn, ConfigJsonMap) of
+        {ok, AvroValue} ->
+            put_config(NameVsn, ConfigJsonMap, AvroValue);
+        {error, Reason} ->
+            ?SLOG(error, #{
+                msg => "plugin_config_validation_failed",
+                name_vsn => NameVsn,
+                reason => Reason
+            }),
+            ok
+    end.
+
 %% @private Backup the current config to a file with a timestamp suffix and
 %% then save the new config to the config file.
 backup_and_write_hocon_bin(NameVsn, HoconBin) ->