fix: bad error message when rule engine schema name is too long
Fixes: https://emqx.atlassian.net/browse/EMQX-10778
This commit is contained in:
parent
aad9b1c27d
commit
c65db82b07
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_schema_registry, [
|
{application, emqx_schema_registry, [
|
||||||
{description, "EMQX Schema Registry"},
|
{description, "EMQX Schema Registry"},
|
||||||
{vsn, "0.1.5"},
|
{vsn, "0.1.6"},
|
||||||
{registered, [emqx_schema_registry_sup]},
|
{registered, [emqx_schema_registry_sup]},
|
||||||
{mod, {emqx_schema_registry_app, []}},
|
{mod, {emqx_schema_registry_app, []}},
|
||||||
{included_applications, [
|
{included_applications, [
|
||||||
|
|
|
@ -64,7 +64,7 @@ get_serde(SchemaName) ->
|
||||||
get_schema(SchemaName) ->
|
get_schema(SchemaName) ->
|
||||||
case
|
case
|
||||||
emqx_config:get(
|
emqx_config:get(
|
||||||
[?CONF_KEY_ROOT, schemas, binary_to_atom(SchemaName)], undefined
|
[?CONF_KEY_ROOT, schemas, schema_name_bin_to_atom(SchemaName)], undefined
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
undefined ->
|
undefined ->
|
||||||
|
@ -333,6 +333,20 @@ async_delete_serdes(Names) ->
|
||||||
to_bin(A) when is_atom(A) -> atom_to_binary(A);
|
to_bin(A) when is_atom(A) -> atom_to_binary(A);
|
||||||
to_bin(B) when is_binary(B) -> B.
|
to_bin(B) when is_binary(B) -> B.
|
||||||
|
|
||||||
|
schema_name_bin_to_atom(Bin) when size(Bin) > 255 ->
|
||||||
|
erlang:throw(
|
||||||
|
iolist_to_binary(
|
||||||
|
io_lib:format(
|
||||||
|
"Name is is too long."
|
||||||
|
" Please provide a shorter name (<= 255 bytes)."
|
||||||
|
" The name that is too long: \"~s\"",
|
||||||
|
[Bin]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
schema_name_bin_to_atom(Bin) ->
|
||||||
|
binary_to_atom(Bin, utf8).
|
||||||
|
|
||||||
-spec serde_to_map(serde()) -> serde_map().
|
-spec serde_to_map(serde()) -> serde_map().
|
||||||
serde_to_map(#serde{} = Serde) ->
|
serde_to_map(#serde{} = Serde) ->
|
||||||
#{
|
#{
|
||||||
|
|
Loading…
Reference in New Issue