|
|
@@ -927,7 +927,7 @@ handle_probe(ConfRootKey, Request) ->
|
|
|
?NO_CONTENT;
|
|
|
{error, #{kind := validation_error} = Reason0} ->
|
|
|
Reason = redact(Reason0),
|
|
|
- ?BAD_REQUEST('TEST_FAILED', map_to_json(Reason));
|
|
|
+ ?BAD_REQUEST('TEST_FAILED', emqx_utils_maps:to_json(Reason));
|
|
|
{error, Reason0} when not is_tuple(Reason0); element(1, Reason0) =/= 'exit' ->
|
|
|
Reason1 =
|
|
|
case Reason0 of
|
|
|
@@ -1426,7 +1426,7 @@ create_or_update_bridge(ConfRootKey, BridgeType, BridgeName, Conf, HttpStatusCod
|
|
|
ok = emqx_resource:validate_name(BridgeName)
|
|
|
catch
|
|
|
throw:Error ->
|
|
|
- ?BAD_REQUEST(map_to_json(Error))
|
|
|
+ ?BAD_REQUEST(emqx_utils_maps:to_json(Error))
|
|
|
end,
|
|
|
case Check of
|
|
|
ok ->
|
|
|
@@ -1443,9 +1443,9 @@ do_create_or_update_bridge(ConfRootKey, BridgeType, BridgeName, Conf, HttpStatus
|
|
|
PreOrPostConfigUpdate =:= pre_config_update;
|
|
|
PreOrPostConfigUpdate =:= post_config_update
|
|
|
->
|
|
|
- ?BAD_REQUEST(map_to_json(redact(Reason)));
|
|
|
+ ?BAD_REQUEST(emqx_utils_maps:to_json(redact(Reason)));
|
|
|
{error, Reason} when is_map(Reason) ->
|
|
|
- ?BAD_REQUEST(map_to_json(redact(Reason)))
|
|
|
+ ?BAD_REQUEST(emqx_utils_maps:to_json(redact(Reason)))
|
|
|
end.
|
|
|
|
|
|
enable_func(true) -> enable;
|
|
|
@@ -1471,19 +1471,6 @@ bin(S) when is_atom(S) ->
|
|
|
bin(S) when is_binary(S) ->
|
|
|
S.
|
|
|
|
|
|
-map_to_json(M0) ->
|
|
|
- %% When dealing with Hocon validation errors, `value' might contain non-serializable
|
|
|
- %% values (e.g.: user_lookup_fun), so we try again without that key if serialization
|
|
|
- %% fails as a best effort.
|
|
|
- M1 = emqx_utils_maps:jsonable_map(M0, fun(K, V) -> {K, emqx_utils_maps:binary_string(V)} end),
|
|
|
- try
|
|
|
- emqx_utils_json:encode(M1)
|
|
|
- catch
|
|
|
- error:_ ->
|
|
|
- M2 = maps:without([value, <<"value">>], M1),
|
|
|
- emqx_utils_json:encode(M2)
|
|
|
- end.
|
|
|
-
|
|
|
to_existing_atom(X) ->
|
|
|
case emqx_utils:safe_to_existing_atom(X, utf8) of
|
|
|
{ok, A} -> A;
|