Skip to content

Commit e0c331a

Browse files
Merge pull request #15059 from rabbitmq/mergify/bp/v4.1.x/pr-15058
Fix empty state field in /api/deprecated-features/used endpoint (backport #15042) (backport #15058)
2 parents a952738 + 520fe4c commit e0c331a

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
@@ -4148,7 +4148,9 @@ list_deprecated_features_test(Config) ->
41484148
?assertEqual(<<"permitted_by_default">>, maps:get(deprecation_phase, Feature)),
41494149
?assertEqual(atom_to_binary(?MODULE), maps:get(provided_by, Feature)),
41504150
?assertEqual(list_to_binary(Desc), maps:get(desc, Feature)),
4151-
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)).
4151+
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)),
4152+
?assert(maps:is_key(state, Feature)),
4153+
?assert(lists:member(maps:get(state, Feature), [<<"permitted">>, <<"denied">>])).
41524154

41534155
list_used_deprecated_features_test(Config) ->
41544156
Desc = "This is a deprecated feature in use",
@@ -4169,7 +4171,8 @@ list_used_deprecated_features_test(Config) ->
41694171
?assertEqual(<<"removed">>, maps:get(deprecation_phase, Feature)),
41704172
?assertEqual(atom_to_binary(?MODULE), maps:get(provided_by, Feature)),
41714173
?assertEqual(list_to_binary(Desc), maps:get(desc, Feature)),
4172-
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)).
4174+
?assertEqual(list_to_binary(DocUrl), maps:get(doc_url, Feature)),
4175+
?assertNot(maps:is_key(state, Feature)).
41734176

41744177
cluster_and_node_tags_test(Config) ->
41754178
Overview = http_get(Config, "/overview"),

0 commit comments

Comments
 (0)