From b70595cebe2dbc9a0e7ce47ec8f1cc74419d4829 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 20:31:06 +0000 Subject: [PATCH] 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 --- .../content/docs/concepts/configuration.mdx | 4 +- docs/src/content/docs/examples/1-n-1.mdx | 2 +- .../content/docs/guides/control-from-code.mdx | 4 +- .../docs/reference/channel-properties.mdx | 10 +-- docs/src/content/docs/reference/json.mdx | 20 +++--- fairmq/JSONParser.cxx | 67 ++++++++++++------- fairmq/plugins/config/Config.cxx | 3 +- test/properties/_jsonparser.cxx | 13 ++-- test/properties/_suboptparser.cxx | 5 +- 9 files changed, 73 insertions(+), 55 deletions(-) diff --git a/docs/src/content/docs/concepts/configuration.mdx b/docs/src/content/docs/concepts/configuration.mdx index fceff5d6..2e040e5b 100644 --- a/docs/src/content/docs/concepts/configuration.mdx +++ b/docs/src/content/docs/concepts/configuration.mdx @@ -107,7 +107,7 @@ The configuration of a sub-channel is a group of properties with the keys `chans ## The config plugin -The config plugin is a part of each device made with `runDevice.h`. It declares the options of the groups Device and Shared memory in the [table of options](/reference/options/), and reads the channel configuration ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L25-L53)). +The config plugin is a part of each device made with `runDevice.h`. It declares the options of the groups Device and Shared memory in the [table of options](/reference/options/), and reads the channel configuration ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L25-L54)). When the device goes into the state `INITIALIZING DEVICE`, the config plugin: @@ -115,7 +115,7 @@ When the device goes into the state `INITIALIZING DEVICE`, the config plugin: 2. Reads the JSON file of `--mq-config` for this value. If there is no `--mq-config`, it reads `--channel-config`. 3. Stores the channel properties with `SetProperties()`. -If the parser throws an exception, the plugin logs the message with the severity `error`, and the device continues without these channels. If `--id` and `--config-key` are empty, the plugin logs a warning and reads nothing. [JSON configuration](/reference/json/#errors) lists the errors. +If the parser throws an exception, the plugin logs the message with the severity `error` and throws the exception again. The device goes to `ERROR` and does not start. If `--id` and `--config-key` are empty, the plugin logs a warning and reads nothing. [JSON configuration](/reference/json/#errors) lists the errors. The device runner makes the plugins of `-P` before the config plugin. In `INITIALIZING DEVICE`, their callbacks thus run first. The config plugin then replaces the values of all channel properties that the configuration also gives. diff --git a/docs/src/content/docs/examples/1-n-1.mdx b/docs/src/content/docs/examples/1-n-1.mdx index e7a27bda..a4f2d3bf 100644 --- a/docs/src/content/docs/examples/1-n-1.mdx +++ b/docs/src/content/docs/examples/1-n-1.mdx @@ -40,7 +40,7 @@ The file has one entry for each device in `fairMQOptions.devices`. This is the e A device uses the entry whose `id` is equal to its `--id`. With `--config-key processor`, the device uses the entry with `"key": "processor"` instead ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L29-L33), -[JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L69)). Thus `processor1` and `processor2` have different +[JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L90)). Thus `processor1` and `processor2` have different IDs, but the same channels. The [JSON configuration](/reference/json/) page describes the format. ## Build the example diff --git a/docs/src/content/docs/guides/control-from-code.mdx b/docs/src/content/docs/guides/control-from-code.mdx index 3e02d785..d2b56230 100644 --- a/docs/src/content/docs/guides/control-from-code.mdx +++ b/docs/src/content/docs/guides/control-from-code.mdx @@ -255,9 +255,9 @@ The test `Config.SetConfig` parses two options and gives the object to the devic ### The device options and the channels The device options, for example `--id`, `--transport`, `--session`, `--mq-config` and `--channel-config`, are the -options of the config plugin ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L56-L87)). In +options of the config plugin ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L57-L88)). In `INITIALIZING DEVICE`, the config plugin also turns `--mq-config` or `--channel-config` into channel properties -([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L22-L53)). A program without `DeviceRunner` has two ways to get +([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L22-L54)). A program without `DeviceRunner` has two ways to get them: - Load the config plugin with a plugin manager, and add its options before the parse. See diff --git a/docs/src/content/docs/reference/channel-properties.mdx b/docs/src/content/docs/reference/channel-properties.mdx index 5c5eab34..fb7be8a6 100644 --- a/docs/src/content/docs/reference/channel-properties.mdx +++ b/docs/src/content/docs/reference/channel-properties.mdx @@ -24,7 +24,7 @@ The keys are case-sensitive. The `--channel-config` parser logs a warning for an ## All properties -The type is the C++ type of the property. The parsers of `--channel-config` and of JSON files convert the values to this type. A value that the parser cannot convert gives the default, without a message ([_jsonparser.cxx](https://github.com/FairRootGroup/FairMQ/blob/dev/test/properties/_jsonparser.cxx#L157-L161)). +The type is the C++ type of the property. The parsers of `--channel-config` and of JSON files convert the values to this type. For a value that it cannot convert, the parser throws `fair::mq::ParserError` ([_jsonparser.cxx](https://github.com/FairRootGroup/FairMQ/blob/dev/test/properties/_jsonparser.cxx#L158-L166)). A missing key gives the default. | Key | Type | Default | Allowed values | Effect | | --- | --- | --- | --- | --- | @@ -44,15 +44,15 @@ The type is the C++ type of the property. The parsers of `--channel-config` and | [`portRangeMin`](#portrangemin-portrangemax-and-autobind) | int | [`22000`](/source/fairmq/Channel.h/#L380) | A TCP port | Lowest port for autobind. | | [`portRangeMax`](#portrangemin-portrangemax-and-autobind) | int | [`23000`](/source/fairmq/Channel.h/#L381) | A TCP port | Highest port for autobind. | | [`autoBind`](#portrangemin-portrangemax-and-autobind) | bool | [`true`](/source/fairmq/Channel.h/#L382-L386) | `true`, `false`, `1`, `0` | Bind to a random port of the range when the bind fails. | -| [`numSockets`](#numsockets) | int | [`0`](/source/fairmq/JSONParser.cxx/#L108) | 0 or more | Number of sub-channels with the same properties. | +| [`numSockets`](#numsockets) | int | [`0`](/source/fairmq/JSONParser.cxx/#L129) | 0 or more | Number of sub-channels with the same properties. | -The JSON parser uses the same defaults ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L90-L105)). The device also uses them for a property that is not set ([Channel.cxx](/source/fairmq/Channel.cxx/#L92-L112)). +The JSON parser uses the same defaults ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L111-L126)). The device also uses them for a property that is not set ([Channel.cxx](/source/fairmq/Channel.cxx/#L92-L112)). ## The properties in detail ### `name` -The name of the channel. In `--channel-config`, write `name=data`, or put the name and a colon before the first key: `data:type=push,...` ([SuboptParser.cxx](/source/fairmq/SuboptParser.cxx/#L91-L98)). Each channel must have a name. Without it, the parsers of JSON files and of `--channel-config` throw `boost::property_tree::ptree_bad_path` ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L107)). The `--channel-config` parser first logs `missing channel name in argument of option --channel-config`. The config plugin logs the exception, and the device gets no channels from this configuration. In the property key, the name is the `` part of `chans...`. +The name of the channel. In `--channel-config`, write `name=data`, or put the name and a colon before the first key: `data:type=push,...` ([SuboptParser.cxx](/source/fairmq/SuboptParser.cxx/#L91-L98)). Each channel must have a name. Without it, the parsers of JSON files and of `--channel-config` throw `boost::property_tree::ptree_bad_path` ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L128)). The `--channel-config` parser first logs `missing channel name in argument of option --channel-config`. The config plugin logs the exception and throws it again, and the device goes to `ERROR`. In the property key, the name is the `` part of `chans...`. A sub-channel has the name `[]`, for example `data[0]`. Before the device attaches a sub-channel, [`Channel::Validate()`](/api/fair/mq/Channel/#Validate) checks this full name ([Channel.cxx](/source/fairmq/Channel.cxx/#L183-L190)). The allowed characters are `a`–`z`, `A`–`Z`, `0`–`9`, `-`, `_`, `[`, `]` and `#`. For another character, the device logs `channel name contains illegal character` and does not attach the sub-channel. The device then goes to `ERROR`: at once for a binding sub-channel, after the time of `--init-timeout` for a connecting sub-channel ([Device.cxx](/source/fairmq/Device.cxx/#L217-L265)). @@ -176,7 +176,7 @@ If the configured port is in use, autobind binds to a random port. The device lo ### `numSockets` -Only in `--channel-config` and on the channel level of a JSON file. For a value above 0, the parser makes this number of sub-channels, all with the properties of the channel ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L108-L122)). +Only in `--channel-config` and on the channel level of a JSON file. For a value above 0, the parser makes this number of sub-channels, all with the properties of the channel ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L129-L143)). - In JSON, the parser ignores the `sockets` array of the channel. All sub-channels get the `address` of the channel. - In `--channel-config`, the parser ignores the `address=` keys. The sub-channels have no address. diff --git a/docs/src/content/docs/reference/json.mdx b/docs/src/content/docs/reference/json.mdx index a1e790af..fb68e86d 100644 --- a/docs/src/content/docs/reference/json.mdx +++ b/docs/src/content/docs/reference/json.mdx @@ -18,7 +18,7 @@ The file of the [1-n-1 example](/examples/1-n-1/) has three entries: one for the ## Structure -The parser reads this tree ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L39-L190)): +The parser reads this tree ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L39-L211)): ```txt fairMQOptions object, required @@ -63,10 +63,10 @@ An entry needs `id` or `key`, otherwise no device can select it. ## How the device finds its entry -The [config plugin](/concepts/configuration/#the-config-plugin) reads the file when the device goes into the state `INITIALIZING DEVICE` ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L25-L53)): +The [config plugin](/concepts/configuration/#the-config-plugin) reads the file when the device goes into the state `INITIALIZING DEVICE` ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L25-L54)): 1. The plugin takes the value of `--config-key`. Without `--config-key`, it takes the value of `--id`. -2. The parser compares this value with the `key` of each device entry. For an entry without `key`, it compares the value with `id` ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L69-L74)). +2. The parser compares this value with the `key` of each device entry. For an entry without `key`, it compares the value with `id` ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L90-L95)). 3. The parser reads the channels of each entry that matches. An entry with a `key` does not match its `id`. Several devices can use the same entry. In the start script of the 1-n-1 example, both processors have their own ID and the same key `processor`: @@ -96,15 +96,13 @@ The entry with the ID `other` has the key `sink`. `--config-key sink` selects it ## `numSockets` -With `numSockets` above 0, the parser makes this number of sub-channels. All of them get the values of the channel, also the `address`. The parser then ignores the `sockets` array ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L108-L122)). [Channel properties](/reference/channel-properties/#numsockets) describes the effect on binding sub-channels. +With `numSockets` above 0, the parser makes this number of sub-channels. All of them get the values of the channel, also the `address`. The parser then ignores the `sockets` array ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L129-L143)). [Channel properties](/reference/channel-properties/#numsockets) describes the effect on binding sub-channels. ## Value types Write strings as JSON strings, numbers as JSON numbers, and booleans as `true` or `false`. [Channel properties](/reference/channel-properties/) gives the type of each property. -:::caution[Wrong types] -The parser reads each value with a default ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L90-L105)). If it cannot convert a value, it uses the default and shows no error. For example, `"sndBufSize": "big"` gives `sndBufSize` 1000. To see the values, start the device with `--severity trace`: the parser then logs each property of each sub-channel. -::: +The parser uses the default of a property only when the key is missing ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L111-L126)). If it cannot convert a value, it throws [`fair::mq::ParserError`](/api/fair/mq/ParserError/). For example, `"sndBufSize": "big"` gives `Invalid value 'big' for channel property 'sndBufSize'`. To see the values, start the device with `--severity trace`: the parser then logs each property of each sub-channel. ## Errors @@ -115,12 +113,12 @@ The parser reads each value with a default ([JSONParser.cxx](/source/fairmq/JSON | A channel has no `name`. | `boost::property_tree::ptree_bad_path` | | The ID is empty. This occurs only when you call the parser from code. | [`fair::mq::ParserError`](/api/fair/mq/ParserError/): ``no device ID provided. Provide with `--id` cmd option`` | | No entry matches the ID or the key. | No error. The device has no channels from the file. | -| A value has the wrong type. | No error. The parser uses the default. | +| A value has the wrong type. | [`fair::mq::ParserError`](/api/fair/mq/ParserError/): `Invalid value '' for channel property ''` | -The config plugin catches the exceptions and logs their message with the severity `error` ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L46-L48)). The device then continues without the channels of the file. If the device has no `--id` and no `--config-key`, the plugin logs the warning `No device ID or config-key provided for the configuration parser.` and does not read the file. +The config plugin catches the exceptions, logs `Invalid channel configuration:` and the message with the severity `error`, and throws the exception again ([Config.cxx](/source/fairmq/plugins/config/Config.cxx/#L46-L49)). The device then goes to `ERROR` in `INITIALIZING DEVICE` and does not start. If the device has no `--id` and no `--config-key`, the plugin logs the warning `No device ID or config-key provided for the configuration parser.` and does not read the file. -:::caution -A device with a broken file can start without channels. If your device does not find a channel, look for an error message from the parser at the start of the log. +:::tip +If your device does not start, look for `Invalid channel configuration:` at the start of the log. ::: ## Parse a file from code diff --git a/fairmq/JSONParser.cxx b/fairmq/JSONParser.cxx index 9a61e47e..d2b15eb8 100644 --- a/fairmq/JSONParser.cxx +++ b/fairmq/JSONParser.cxx @@ -58,6 +58,27 @@ Properties JSONParser(const string& filename, const string& deviceId) namespace helper { +namespace +{ + +// ptree::get(key, default) also returns the default for a value of the wrong type. +// Use the default only for a missing key. +template +T Get(const ptree& tree, const string& key, const T& defaultValue) +{ + auto const child = tree.get_child_optional(key); + if (!child) { + return defaultValue; + } + try { + return child->get_value(); + } catch (ptree_bad_data const&) { + throw ParserError(ToString("Invalid value '", child->data(), "' for channel property '", key, "'")); + } +} + +} // namespace + Properties DeviceParser(const ptree& fairMQOptions, const string& deviceId) { Properties properties; @@ -92,20 +113,20 @@ void ChannelParser(const ptree& tree, Properties& properties) commonProperties.emplace("method", cn.second.get("method", Channel::DefaultMethod)); commonProperties.emplace("address", cn.second.get("address", Channel::DefaultAddress)); commonProperties.emplace("transport", cn.second.get("transport", Channel::DefaultTransportName)); - commonProperties.emplace("sndBufSize", cn.second.get("sndBufSize", Channel::DefaultSndBufSize)); - commonProperties.emplace("rcvBufSize", cn.second.get("rcvBufSize", Channel::DefaultRcvBufSize)); - commonProperties.emplace("sndKernelSize", cn.second.get("sndKernelSize", Channel::DefaultSndKernelSize)); - commonProperties.emplace("rcvKernelSize", cn.second.get("rcvKernelSize", Channel::DefaultRcvKernelSize)); - commonProperties.emplace("sndTimeoutMs", cn.second.get("sndTimeoutMs", Channel::DefaultSndTimeoutMs)); - commonProperties.emplace("rcvTimeoutMs", cn.second.get("rcvTimeoutMs", Channel::DefaultRcvTimeoutMs)); - commonProperties.emplace("linger", cn.second.get("linger", Channel::DefaultLinger)); - commonProperties.emplace("rateLogging", cn.second.get("rateLogging", Channel::DefaultRateLogging)); - commonProperties.emplace("portRangeMin", cn.second.get("portRangeMin", Channel::DefaultPortRangeMin)); - commonProperties.emplace("portRangeMax", cn.second.get("portRangeMax", Channel::DefaultPortRangeMax)); - commonProperties.emplace("autoBind", cn.second.get("autoBind", Channel::DefaultAutoBind)); + commonProperties.emplace("sndBufSize", Get(cn.second, "sndBufSize", Channel::DefaultSndBufSize)); + commonProperties.emplace("rcvBufSize", Get(cn.second, "rcvBufSize", Channel::DefaultRcvBufSize)); + commonProperties.emplace("sndKernelSize", Get(cn.second, "sndKernelSize", Channel::DefaultSndKernelSize)); + commonProperties.emplace("rcvKernelSize", Get(cn.second, "rcvKernelSize", Channel::DefaultRcvKernelSize)); + commonProperties.emplace("sndTimeoutMs", Get(cn.second, "sndTimeoutMs", Channel::DefaultSndTimeoutMs)); + commonProperties.emplace("rcvTimeoutMs", Get(cn.second, "rcvTimeoutMs", Channel::DefaultRcvTimeoutMs)); + commonProperties.emplace("linger", Get(cn.second, "linger", Channel::DefaultLinger)); + commonProperties.emplace("rateLogging", Get(cn.second, "rateLogging", Channel::DefaultRateLogging)); + commonProperties.emplace("portRangeMin", Get(cn.second, "portRangeMin", Channel::DefaultPortRangeMin)); + commonProperties.emplace("portRangeMax", Get(cn.second, "portRangeMax", Channel::DefaultPortRangeMax)); + commonProperties.emplace("autoBind", Get(cn.second, "autoBind", Channel::DefaultAutoBind)); string name = cn.second.get("name"); - int numSockets = cn.second.get("numSockets", 0); + int numSockets = Get(cn.second, "numSockets", 0); if (numSockets > 0) { LOG(trace) << name << ":"; @@ -144,17 +165,17 @@ void SubChannelParser(const ptree& channelTree, Properties& properties, const st newProperties["method"] = sn.second.get("method", boost::any_cast(commonProperties.at("method"))); newProperties["address"] = sn.second.get("address", boost::any_cast(commonProperties.at("address"))); newProperties["transport"] = sn.second.get("transport", boost::any_cast(commonProperties.at("transport"))); - newProperties["sndBufSize"] = sn.second.get("sndBufSize", boost::any_cast(commonProperties.at("sndBufSize"))); - newProperties["rcvBufSize"] = sn.second.get("rcvBufSize", boost::any_cast(commonProperties.at("rcvBufSize"))); - newProperties["sndKernelSize"] = sn.second.get("sndKernelSize", boost::any_cast(commonProperties.at("sndKernelSize"))); - newProperties["rcvKernelSize"] = sn.second.get("rcvKernelSize", boost::any_cast(commonProperties.at("rcvKernelSize"))); - newProperties["sndTimeoutMs"] = sn.second.get("sndTimeoutMs", boost::any_cast(commonProperties.at("sndTimeoutMs"))); - newProperties["rcvTimeoutMs"] = sn.second.get("rcvTimeoutMs", boost::any_cast(commonProperties.at("rcvTimeoutMs"))); - newProperties["linger"] = sn.second.get("linger", boost::any_cast(commonProperties.at("linger"))); - newProperties["rateLogging"] = sn.second.get("rateLogging", boost::any_cast(commonProperties.at("rateLogging"))); - newProperties["portRangeMin"] = sn.second.get("portRangeMin", boost::any_cast(commonProperties.at("portRangeMin"))); - newProperties["portRangeMax"] = sn.second.get("portRangeMax", boost::any_cast(commonProperties.at("portRangeMax"))); - newProperties["autoBind"] = sn.second.get("autoBind", boost::any_cast(commonProperties.at("autoBind"))); + newProperties["sndBufSize"] = Get(sn.second, "sndBufSize", boost::any_cast(commonProperties.at("sndBufSize"))); + newProperties["rcvBufSize"] = Get(sn.second, "rcvBufSize", boost::any_cast(commonProperties.at("rcvBufSize"))); + newProperties["sndKernelSize"] = Get(sn.second, "sndKernelSize", boost::any_cast(commonProperties.at("sndKernelSize"))); + newProperties["rcvKernelSize"] = Get(sn.second, "rcvKernelSize", boost::any_cast(commonProperties.at("rcvKernelSize"))); + newProperties["sndTimeoutMs"] = Get(sn.second, "sndTimeoutMs", boost::any_cast(commonProperties.at("sndTimeoutMs"))); + newProperties["rcvTimeoutMs"] = Get(sn.second, "rcvTimeoutMs", boost::any_cast(commonProperties.at("rcvTimeoutMs"))); + newProperties["linger"] = Get(sn.second, "linger", boost::any_cast(commonProperties.at("linger"))); + newProperties["rateLogging"] = Get(sn.second, "rateLogging", boost::any_cast(commonProperties.at("rateLogging"))); + newProperties["portRangeMin"] = Get(sn.second, "portRangeMin", boost::any_cast(commonProperties.at("portRangeMin"))); + newProperties["portRangeMax"] = Get(sn.second, "portRangeMax", boost::any_cast(commonProperties.at("portRangeMax"))); + newProperties["autoBind"] = Get(sn.second, "autoBind", boost::any_cast(commonProperties.at("autoBind"))); LOG(trace) << "" << channelName << "[" << i << "]:"; for (auto& p : newProperties) { diff --git a/fairmq/plugins/config/Config.cxx b/fairmq/plugins/config/Config.cxx index 0195839c..b3602019 100644 --- a/fairmq/plugins/config/Config.cxx +++ b/fairmq/plugins/config/Config.cxx @@ -44,7 +44,8 @@ Config::Config(const string& name, Plugin::Version version, const string& mainta LOG(info) << "fair::mq::plugins::Config: no channels configuration provided via --mq-config or --channel-config"; } } catch (exception& e) { - LOG(error) << e.what(); + LOG(error) << "Invalid channel configuration: " << e.what(); + throw; } } else { LOG(warn) << "No device ID or config-key provided for the configuration parser."; diff --git a/test/properties/_jsonparser.cxx b/test/properties/_jsonparser.cxx index 3a7eca3d..1f9fbdb7 100644 --- a/test/properties/_jsonparser.cxx +++ b/test/properties/_jsonparser.cxx @@ -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) diff --git a/test/properties/_suboptparser.cxx b/test/properties/_suboptparser.cxx index 2e0c7939..bdd71787 100644 --- a/test/properties/_suboptparser.cxx +++ b/test/properties/_suboptparser.cxx @@ -91,10 +91,9 @@ TEST(SuboptParser, Errors) EXPECT_THROW(SuboptParser({"name=data"}, ""), ParserError); } -// Known defect: see JSONParser.DISABLED_RejectsValuesOfTheWrongType. -TEST(SuboptParser, DISABLED_RejectsValuesOfTheWrongType) +TEST(SuboptParser, RejectsValuesOfTheWrongType) { - EXPECT_THROW(SuboptParser({"name=data,sndBufSize=big"}, "dev"), boost::property_tree::ptree_bad_data); + EXPECT_THROW(SuboptParser({"name=data,sndBufSize=big"}, "dev"), ParserError); } } // namespace