fix(config): reject channel properties of the wrong type

- ptree::get(key, default) returns the default also for a value that
  does not convert, so a typo (e.g. sndBufSize=big) silently gave the
  default value
- Use the default only for a missing key; throw ParserError with the
  key and the value for a value of the wrong type
- Rethrow parser errors in the config plugin: before, the device
  logged the error and continued without its channel configuration
- Enable JSONParser and SuboptParser RejectsValuesOfTheWrongType
- Update the documentation pages that described the defect, and
  the source line links into the changed files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-04 20:31:06 +00:00
committed by Dennis Klein
parent 442b203d0d
commit b70595cebe
9 changed files with 73 additions and 55 deletions

View File

@@ -154,16 +154,15 @@ TEST(JSONParser, Errors)
boost::property_tree::ptree_bad_path);
}
// Known defect: ChannelParser() reads the values with ptree::get(key, default).
// That overload returns the default for a value of the wrong type, so a typo
// (e.g. "sndBufSize": "big") silently gives the default. Enable this test
// with the fix.
TEST(JSONParser, DISABLED_RejectsValuesOfTheWrongType)
// A typo (e.g. "sndBufSize": "big") must not silently give the default.
TEST(JSONParser, RejectsValuesOfTheWrongType)
{
EXPECT_THROW(Parse(R"({"fairMQOptions": {"devices": [{"id": "a", "channels": [{"name": "c", "sndBufSize": "big"}]}]}})", "a"),
boost::property_tree::ptree_bad_data);
ParserError);
EXPECT_THROW(Parse(R"({"fairMQOptions": {"devices": [{"id": "a", "channels": [{"name": "c", "autoBind": "maybe"}]}]}})", "a"),
boost::property_tree::ptree_bad_data);
ParserError);
EXPECT_THROW(Parse(R"({"fairMQOptions": {"devices": [{"id": "a", "channels": [{"name": "c", "sockets": [{"linger": "1.5"}]}]}]}})", "a"),
ParserError);
}
TEST(JSONParser, File)