Skip to content

Commit cb9c8ca

Browse files
Merge pull request #15042 from bas0N/fix/14340
Fix empty state field in /api/deprecated-features/used endpoint
2 parents 9c56475 + d2a3a60 commit cb9c8ca

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

deps/rabbit/src/rabbit_depr_ff_extra.erl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ cli_info0(DeprecatedFeature) ->
5858

5959
App = maps:get(provided_by, FeatureProps),
6060
DeprecationPhase = maps:get(deprecation_phase, FeatureProps, ""),
61-
State = maps:get(state, FeatureProps, ""),
6261
Desc = maps:get(desc, FeatureProps, ""),
6362
DocUrl = maps:get(doc_url, FeatureProps, ""),
64-
Info = #{name => FeatureName,
65-
desc => unicode:characters_to_binary(Desc),
66-
deprecation_phase => DeprecationPhase,
67-
state => State,
68-
doc_url => unicode:characters_to_binary(DocUrl),
69-
provided_by => App},
63+
BaseInfo = #{name => FeatureName,
64+
desc => unicode:characters_to_binary(Desc),
65+
deprecation_phase => DeprecationPhase,
66+
doc_url => unicode:characters_to_binary(DocUrl),
67+
provided_by => App},
68+
Info = maps:merge(BaseInfo,
69+
case maps:find(state, FeatureProps) of
70+
{ok, State} -> #{state => State};
71+
error -> #{}
72+
end),
7073
[Info | Acc]
7174
end, [], lists:sort(maps:keys(DeprecatedFeature))).

deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4218,7 +4218,9 @@ list_deprecated_features_test(Config) ->
42184218
?assertEqual(<<"permitted_by_default">>, maps:get(deprecation_phase, Feature)),
42194219
?assertEqual(atom_to_binary(?MODULE), maps:get(provided_by, Feature)),
42204220
?assertEqual(list_to_binary(Desc), maps:get(desc, Feature)),
4221-
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)).
4221+
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)),
4222+
?assert(maps:is_key(state, Feature)),
4223+
?assert(lists:member(maps:get(state, Feature), [<<"permitted">>, <<"denied">>])).
42224224

42234225
list_used_deprecated_features_test(Config) ->
42244226
Desc = "This is a deprecated feature in use",
@@ -4239,7 +4241,8 @@ list_used_deprecated_features_test(Config) ->
42394241
?assertEqual(<<"removed">>, maps:get(deprecation_phase, Feature)),
42404242
?assertEqual(atom_to_binary(?MODULE), maps:get(provided_by, Feature)),
42414243
?assertEqual(list_to_binary(Desc), maps:get(desc, Feature)),
4242-
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)).
4244+
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)),
4245+
?assertNot(maps:is_key(state, Feature)).
42434246

42444247
cluster_and_node_tags_test(Config) ->
42454248
Overview = http_get(Config, "/overview"),

0 commit comments

Comments
 (0)