diff --git a/apps/emqx/src/emqx_config.erl b/apps/emqx/src/emqx_config.erl index dc1c6d7c5..529a09bb7 100644 --- a/apps/emqx/src/emqx_config.erl +++ b/apps/emqx/src/emqx_config.erl @@ -214,15 +214,13 @@ get_default_value([RootName | _] = KeyPath) -> BinKeyPath = [bin(Key) || Key <- KeyPath], case find_raw([RootName]) of {ok, RawConf} -> - RawConf1 = emqx_map_lib:deep_remove(BinKeyPath, RawConf), - SchemaMod = get_schema_mod(RootName), - try fill_defaults(SchemaMod, RawConf1) of FullConf -> + RawConf1 = emqx_map_lib:deep_remove(BinKeyPath, #{bin(RootName) => RawConf}), + try fill_defaults(get_schema_mod(RootName), RawConf1) of FullConf -> case emqx_map_lib:deep_find(BinKeyPath, FullConf) of {not_found, _, _} -> {error, no_default_value}; {ok, Val} -> {ok, Val} end - catch error:_ -> - {error, required_conf} + catch error : Reason -> {error, Reason} end; {not_found, _, _} -> {error, {rootname_not_found, RootName}} diff --git a/apps/emqx/src/emqx_config_handler.erl b/apps/emqx/src/emqx_config_handler.erl index e4285b503..2a1e70501 100644 --- a/apps/emqx/src/emqx_config_handler.erl +++ b/apps/emqx/src/emqx_config_handler.erl @@ -82,8 +82,8 @@ handle_call({add_child, ConfKeyPath, HandlerName}, _From, handle_call({change_config, SchemaModule, ConfKeyPath, UpdateArgs}, _From, #{handlers := Handlers} = State) -> - OldConf = emqx_config:get_root(ConfKeyPath), - OldRawConf = emqx_config:get_root_raw(ConfKeyPath), + OldConf = emqx_config:get([]), + OldRawConf = emqx_config:get_raw([]), Result = try {NewRawConf, OverrideConf} = process_upadate_request(ConfKeyPath, OldRawConf, Handlers, UpdateArgs), diff --git a/apps/emqx_management/src/emqx_mgmt_api_configs.erl b/apps/emqx_management/src/emqx_mgmt_api_configs.erl index 2c37ee1a2..72fc179eb 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_configs.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_configs.erl @@ -46,7 +46,7 @@ -define(MAX_DEPTH, 1). --define(ERR_MSG(MSG), io_lib:format("~p", [MSG])). +-define(ERR_MSG(MSG), list_to_binary(io_lib:format("~p", [MSG]))). api_spec() -> {config_apis() ++ [config_reset_api()], []}.