diff --git a/python/tests/test_config.py b/python/tests/test_config.py index c0c68409..1614e355 100644 --- a/python/tests/test_config.py +++ b/python/tests/test_config.py @@ -528,6 +528,20 @@ def test_expanded_json(self): config = json.loads(self.config.expanded_json) self.assertEqual(config['output']['output_dir'], 'some/path/output') + def test_empty_connection_overrides(self): + contents = """ + { + "manifest": { + "$CIRCUIT_DIR": "./circuit" + }, + "network": "$CIRCUIT_DIR/circuit_config.json", + "run": { "random_seed": 12345, "dt": 0.05, "tstop": 1000 }, + "connection_overrides": [] + } + """ + conf = SimulationConfig(contents, "./") + self.assertEqual(conf.connection_overrides(), []) + def test_run(self): contents = """ { @@ -557,7 +571,7 @@ def test_simulation_config_failures(self): }, "network": "$CIRCUIT_DIR/circuit_config.json", "run": { "random_seed": 12345, "dt": 0.05, "tstop": 1000 }, - "connection_overrides": { } + "connection_overrides": {"foo": "bar"} } """ SimulationConfig(contents, "./") diff --git a/src/config.cpp b/src/config.cpp index c177550a..23f23e47 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1080,7 +1080,12 @@ class SimulationConfig::Parser std::vector result; const auto connIt = _json.find("connection_overrides"); - if (connIt == _json.end()) { + // nlohmann::json::flatten().unflatten() converts empty containers to `null`: + // https://json.nlohmann.me/api/basic_json/unflatten/#notes + // so we can't tell the difference between {} and []; however, since these are + // empty, we will assume the intent was to have no connection_overrides and forgo + // better error reporting + if (connIt == _json.end() || connIt->is_null()) { return result; }