Merge pull request #13419 from zhongwencool/port-pr
Port: some minor bug fixes from master
This commit is contained in:
commit
29d7a511f1
|
@ -890,7 +890,7 @@ fields("ws_opts") ->
|
|||
)},
|
||||
{"max_frame_size",
|
||||
sc(
|
||||
hoconsc:union([infinity, integer()]),
|
||||
hoconsc:union([infinity, pos_integer()]),
|
||||
#{
|
||||
default => infinity,
|
||||
desc => ?DESC(fields_ws_opts_max_frame_size)
|
||||
|
@ -970,7 +970,7 @@ fields("tcp_opts") ->
|
|||
[
|
||||
{"active_n",
|
||||
sc(
|
||||
integer(),
|
||||
non_neg_integer(),
|
||||
#{
|
||||
default => 100,
|
||||
desc => ?DESC(fields_tcp_opts_active_n)
|
||||
|
|
|
@ -237,6 +237,12 @@ load_config(Bin, Opts) when is_binary(Bin) ->
|
|||
case hocon:binary(Bin) of
|
||||
{ok, RawConf} ->
|
||||
load_config_from_raw(RawConf, Opts);
|
||||
%% Type is scan_error, parse_error...
|
||||
{error, {Type, Meta = #{reason := Reason}}} ->
|
||||
{error, Meta#{
|
||||
reason => unicode:characters_to_binary(Reason),
|
||||
type => Type
|
||||
}};
|
||||
{error, Reason} ->
|
||||
{error, Reason}
|
||||
end.
|
||||
|
|
|
@ -364,10 +364,10 @@ configs(get, #{query_string := QueryStr, headers := Headers}, _Req) ->
|
|||
{error, _} = Error -> {400, #{code => 'INVALID_ACCEPT', message => ?ERR_MSG(Error)}}
|
||||
end;
|
||||
configs(put, #{body := Conf, query_string := #{<<"mode">> := Mode} = QS}, _Req) ->
|
||||
IngnoreReadonly = maps:get(<<"ignore_readonly">>, QS, false),
|
||||
IgnoreReadonly = maps:get(<<"ignore_readonly">>, QS, false),
|
||||
case
|
||||
emqx_conf_cli:load_config(Conf, #{
|
||||
mode => Mode, log => none, ignore_readonly => IngnoreReadonly
|
||||
mode => Mode, log => none, ignore_readonly => IgnoreReadonly
|
||||
})
|
||||
of
|
||||
ok ->
|
||||
|
|
|
@ -310,7 +310,7 @@ t_configs_key(_Config) ->
|
|||
ReadOnlyBin = iolist_to_binary(hocon_pp:do(ReadOnlyConf, #{})),
|
||||
{error, ReadOnlyError} = update_configs_with_binary(ReadOnlyBin),
|
||||
?assertEqual(<<"{\"errors\":\"Cannot update read-only key 'cluster'.\"}">>, ReadOnlyError),
|
||||
?assertMatch({ok, <<>>}, update_configs_with_binary(ReadOnlyBin, _InogreReadonly = true)),
|
||||
?assertMatch({ok, <<>>}, update_configs_with_binary(ReadOnlyBin, _IgnoreReadonly = true)),
|
||||
ok.
|
||||
|
||||
t_get_configs_in_different_accept(_Config) ->
|
||||
|
@ -443,13 +443,38 @@ t_create_webhook_v1_bridges_api(Config) ->
|
|||
ok.
|
||||
|
||||
t_config_update_parse_error(_Config) ->
|
||||
BadHoconList = [
|
||||
<<"not an object">>,
|
||||
<<"a = \"tlsv1\"\"\"3e-01">>
|
||||
],
|
||||
lists:map(
|
||||
fun(BadHocon) ->
|
||||
{error, ParseError} = update_configs_with_binary(BadHocon),
|
||||
?assertMatch(
|
||||
{error, <<"{\"errors\":\"{parse_error,", _/binary>>},
|
||||
update_configs_with_binary(<<"not an object">>)
|
||||
#{
|
||||
<<"errors">> :=
|
||||
#{
|
||||
<<"line">> := 1,
|
||||
<<"reason">> := _,
|
||||
<<"type">> := <<"parse_error">>
|
||||
}
|
||||
},
|
||||
emqx_utils_json:decode(ParseError)
|
||||
)
|
||||
end,
|
||||
BadHoconList
|
||||
),
|
||||
|
||||
{error, ScanError} = update_configs_with_binary(<<"a=测试"/utf8>>),
|
||||
?assertMatch(
|
||||
{error, <<"{\"errors\":\"{parse_error,", _/binary>>},
|
||||
update_configs_with_binary(<<"a = \"tlsv1\"\"\"3e-01">>)
|
||||
#{
|
||||
<<"errors">> := #{
|
||||
<<"line">> := 1,
|
||||
<<"reason">> := _,
|
||||
<<"type">> := <<"scan_error">>
|
||||
}
|
||||
},
|
||||
emqx_utils_json:decode(ScanError)
|
||||
).
|
||||
|
||||
t_config_update_unknown_root(_Config) ->
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%% -*- mode: erlang -*-
|
||||
{application, emqx_modules, [
|
||||
{description, "EMQX Modules"},
|
||||
{vsn, "5.0.26"},
|
||||
{vsn, "5.0.27"},
|
||||
{modules, []},
|
||||
{applications, [kernel, stdlib, emqx, emqx_ctl, observer_cli]},
|
||||
{mod, {emqx_modules_app, []}},
|
||||
|
|
|
@ -46,8 +46,13 @@ cmd(["load", Mod]) ->
|
|||
Nodes ->
|
||||
case emqx_utils:safe_to_existing_atom(Mod) of
|
||||
{ok, Module} ->
|
||||
case code:get_object_code(Module) of
|
||||
error ->
|
||||
emqx_ctl:print("Module(~s)'s object code not found~n", [Mod]);
|
||||
_ ->
|
||||
Res = recon:remote_load(Nodes, Module),
|
||||
emqx_ctl:print("Loaded ~p module on ~p: ~p~n", [Module, Nodes, Res]);
|
||||
emqx_ctl:print("Loaded ~p module on ~p: ~p~n", [Module, Nodes, Res])
|
||||
end;
|
||||
{error, Reason} ->
|
||||
emqx_ctl:print("Module(~s) not found: ~p~n", [Mod, Reason])
|
||||
end
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix garbled hints in crash log message when calling /configs API
|
Loading…
Reference in New Issue