Skip to content

Commit 0c37788

Browse files
committed
rgw/notification: Fix the filter_rules to be array vs dict in json output.
FilterRules when processed as dict in json, emits samy key name for prefix, suffix causing failure while parsing the json notification output. So change the type FilterRules from JsonDict to Array while dumping in json. Signed-off-by: kchheda3 <[email protected]>
1 parent 395ff95 commit 0c37788

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/rgw/rgw_pubsub.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,24 @@ void set_event_id(std::string& id, const std::string& hash, const utime_t& ts) {
2323
}
2424

2525
void rgw_s3_key_filter::dump(Formatter *f) const {
26+
if (!has_content()) {
27+
return;
28+
}
29+
f->open_array_section("FilterRules");
2630
if (!prefix_rule.empty()) {
27-
f->open_object_section("FilterRule");
31+
f->open_object_section("");
2832
::encode_json("Name", "prefix", f);
2933
::encode_json("Value", prefix_rule, f);
3034
f->close_section();
3135
}
3236
if (!suffix_rule.empty()) {
33-
f->open_object_section("FilterRule");
37+
f->open_object_section("");
3438
::encode_json("Name", "suffix", f);
3539
::encode_json("Value", suffix_rule, f);
3640
f->close_section();
3741
}
3842
if (!regex_rule.empty()) {
39-
f->open_object_section("FilterRule");
43+
f->open_object_section("");
4044
::encode_json("Name", "regex", f);
4145
::encode_json("Value", regex_rule, f);
4246
f->close_section();
@@ -97,8 +101,12 @@ bool rgw_s3_key_filter::has_content() const {
97101
}
98102

99103
void rgw_s3_key_value_filter::dump(Formatter *f) const {
104+
if (!has_content()) {
105+
return;
106+
}
107+
f->open_array_section("FilterRules");
100108
for (const auto& key_value : kv) {
101-
f->open_object_section("FilterRule");
109+
f->open_object_section("");
102110
::encode_json("Name", key_value.first, f);
103111
::encode_json("Value", key_value.second, f);
104112
f->close_section();

0 commit comments

Comments
 (0)