From: kchheda3 Date: Tue, 27 Feb 2024 20:59:15 +0000 (-0500) Subject: rgw/notification: Fix the filter_rules to be array vs dict in json output. X-Git-Tag: v20.0.0~2391^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F55796%2Fhead;p=ceph.git 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 --- diff --git a/src/rgw/rgw_pubsub.cc b/src/rgw/rgw_pubsub.cc index 7031c2363f0b..79d9f989cc4f 100644 --- a/src/rgw/rgw_pubsub.cc +++ b/src/rgw/rgw_pubsub.cc @@ -23,20 +23,24 @@ void set_event_id(std::string& id, const std::string& hash, const utime_t& ts) { } void rgw_s3_key_filter::dump(Formatter *f) const { + if (!has_content()) { + return; + } + f->open_array_section("FilterRules"); if (!prefix_rule.empty()) { - f->open_object_section("FilterRule"); + f->open_object_section(""); ::encode_json("Name", "prefix", f); ::encode_json("Value", prefix_rule, f); f->close_section(); } if (!suffix_rule.empty()) { - f->open_object_section("FilterRule"); + f->open_object_section(""); ::encode_json("Name", "suffix", f); ::encode_json("Value", suffix_rule, f); f->close_section(); } if (!regex_rule.empty()) { - f->open_object_section("FilterRule"); + f->open_object_section(""); ::encode_json("Name", "regex", f); ::encode_json("Value", regex_rule, f); f->close_section(); @@ -97,8 +101,12 @@ bool rgw_s3_key_filter::has_content() const { } void rgw_s3_key_value_filter::dump(Formatter *f) const { + if (!has_content()) { + return; + } + f->open_array_section("FilterRules"); for (const auto& key_value : kv) { - f->open_object_section("FilterRule"); + f->open_object_section(""); ::encode_json("Name", key_value.first, f); ::encode_json("Value", key_value.second, f); f->close_section();