brbzull0 commented on code in PR #13609:
URL: https://github.com/apache/trafficserver/pull/13609#discussion_r3905719627
##########
include/mgmt/rpc/jsonrpc/json/YAMLCodec.h:
##########
@@ -268,6 +268,7 @@ class yamlcpp_json_encoder
encode(const specs::RPCResponseInfo &resp)
{
YAML::Emitter json;
+ json.SetNullFormat(YAML::LowerNull);
json << YAML::DoubleQuoted << YAML::Flow;
encode(resp, json);
Review Comment:
Addressed in 81a52a9110: the `DoubleQuoted`/`Flow`/`LowerNull` idiom is now
`ts::Yaml::configure_json_emitter()` in `include/tsutil/YamlCfg.h`, and all
emitters call it.
It also picked up two emitters this PR had missed —
`SSLMultiCertMarshaller::to_json` and `StorageMarshaller::to_json` build their
own emitters off the RPC path. Neither can produce a null node today, so
nothing was broken, but both were one null away from the same bug, which is
exactly the risk you described.
The invariant is now greppable:
```
$ git grep -n 'SetNullFormat\|YAML::DoubleQuoted' -- src/ include/
include/tsutil/YamlCfg.h:54: emitter.SetNullFormat(YAML::LowerNull);
include/tsutil/YamlCfg.h:55: emitter << YAML::DoubleQuoted << YAML::Flow;
```
--
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]