brbzull0 commented on code in PR #13609:
URL: https://github.com/apache/trafficserver/pull/13609#discussion_r3948927811


##########
src/mgmt/rpc/handlers/hostdb/HostDB.cc:
##########
@@ -82,7 +82,7 @@ template <> struct convert<HostDBCache> {
   static Node
   encode(const HostDBCache *const hostDB, std::string_view hostname)
   {
-    Node partitions;
+    Node partitions{YAML::NodeType::Sequence};

Review Comment:
   Added in 86119e63f: 
`tests/gold_tests/traffic_ctl/traffic_ctl_json_null.test.py`.
   
   It runs against a freshly started server with an empty HostDB and asserts 
that
   `hostdb status` output parses under a strict parser, and that `partitions` is
   `[]` rather than null. It covers both entry points into the emitter: the
   flagless client-printer path through `BasePrinter::write_output_json`, and
   `-f json` through the full envelope. The server-side encoder is exercised
   directly via `rpc invoke get_hostdb_status`.
   
   Verified in both directions: 7/7 assertions pass with the fix, 5/7 fail with
   all five hunks reverted.
   
   A gold file cannot catch this class of bug, since it matches `~` happily
   forever. The new `validate_is_valid_json()` helper pipes stdout through
   `json.loads` instead.



##########
src/mgmt/rpc/handlers/plugins/Plugins.cc:
##########
@@ -100,7 +100,7 @@ get_plugin_list(std::string_view const & /* id ATS_UNUSED 
*/, YAML::Node const &
 
     data["source"] = summary.source;
 
-    YAML::Node plugins;
+    YAML::Node plugins{YAML::NodeType::Sequence};

Review Comment:
   Covered by the same test added in 86119e63f.
   
   `plugin list` still ignores the format flag and prints the human-readable
   table, so there is no CLI path to assert on yet. The assertion goes through
   `rpc invoke admin_plugin_get_list` with no plugins loaded, which exercises 
the
   server encoder and checks that `plugins` is `[]` rather than null.
   
   The test carries a comment naming the exact line to add once `plugin list`
   honours `-f json`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to