diff --git a/apps/emqx_schema_validation/src/emqx_schema_validation.app.src b/apps/emqx_schema_validation/src/emqx_schema_validation.app.src index 2dfe710db..31b2a30fc 100644 --- a/apps/emqx_schema_validation/src/emqx_schema_validation.app.src +++ b/apps/emqx_schema_validation/src/emqx_schema_validation.app.src @@ -1,6 +1,6 @@ {application, emqx_schema_validation, [ {description, "EMQX Schema Validation"}, - {vsn, "0.1.1"}, + {vsn, "0.1.2"}, {registered, [emqx_schema_validation_sup, emqx_schema_validation_registry]}, {mod, {emqx_schema_validation_app, []}}, {applications, [ diff --git a/apps/emqx_schema_validation/src/emqx_schema_validation_schema.erl b/apps/emqx_schema_validation/src/emqx_schema_validation_schema.erl index fa9461745..8984d1066 100644 --- a/apps/emqx_schema_validation/src/emqx_schema_validation_schema.erl +++ b/apps/emqx_schema_validation/src/emqx_schema_validation_schema.erl @@ -259,6 +259,8 @@ do_validate_unique_schema_checks( do_validate_unique_schema_checks([_Check | Rest], Seen, Duplicated) -> do_validate_unique_schema_checks(Rest, Seen, Duplicated). +validate_unique_topics([]) -> + {error, <<"at least one topic filter must be defined">>}; validate_unique_topics(Topics) -> Grouped = maps:groups_from_list( fun(T) -> T end, diff --git a/apps/emqx_schema_validation/test/emqx_schema_validation_tests.erl b/apps/emqx_schema_validation/test/emqx_schema_validation_tests.erl index a75e4b556..d6e18da92 100644 --- a/apps/emqx_schema_validation/test/emqx_schema_validation_tests.erl +++ b/apps/emqx_schema_validation/test/emqx_schema_validation_tests.erl @@ -117,6 +117,19 @@ schema_test_() -> ) ]) )}, + {"topics must be non-empty", + ?_assertThrow( + {_Schema, [ + #{ + reason := <<"at least one topic filter must be defined", _/binary>>, + value := [], + kind := validation_error + } + ]}, + parse_and_check([ + validation(<<"foo">>, [sql_check()], #{<<"topics">> => []}) + ]) + )}, {"foreach expression is not allowed", ?_assertThrow( {_Schema, [ diff --git a/changes/ee/fix-13420.en.md b/changes/ee/fix-13420.en.md new file mode 100644 index 000000000..994ee8a88 --- /dev/null +++ b/changes/ee/fix-13420.en.md @@ -0,0 +1 @@ +Added a schema validation to forbid empty topic filter lists when configuring a Schema Validation.