Repository navigation
Not planned
Labels
known-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposwontfixThis will not be worked on
Description
Part of #138
Popularity: 1/7 corpus consumers (moqx)
Related issues
- Distinct from Parser/Semantics: strict config parser semantics absent (Holoscan keeps reflect-cpp test-only; triaged in #131) #151 (Holoscan strict YAML 1.2 scalar coercion, lexical numeric-kind, reserved envelopes, and DOM node budgets, triaged out-of-scope in Triage decision: Holoscan strict YAML 1.2 scalars, lexical numeric-kind, reserved envelopes, and DOM node budgets (out of scope) #131). Duplicate mapping key detection and propagating errors on non-scalar mapping keys are core
rfl::yaml::Readercorrectness bugs rather than YAML 1.2 schema coercion. - Related fork maps: Map (Lane 1): Core Hygiene & Perf #85 (Core Hygiene & Perf), Map (Lane 5): Structured Diagnostics #89 (Structured Diagnostics).
Evidence in openmoq/moqx (60bab7f13925acbaf578670223e660d71e891547)
moqx had to build a dedicated 137-line YAML::EventHandler pre-pass (rejectDuplicateKeys) that parses every YAML configuration file a second time before handing the raw text to rfl::yaml::read:
src/config/loader/YamlDuplicateKeys.h#L13-L19:/// Rejects a YAML document that repeats a key within one mapping, or uses a /// collection as a mapping key. /// yaml-cpp keeps every entry of a repeated key; the reflect step then silently /// drops or keeps the extras. /// Throws std::runtime_error naming the key and line. /// Throws YAML::Exception on malformed YAML. void rejectDuplicateKeys(const std::string& content);
src/config/YamlDuplicateKeys.cpp#L23-L111: implementsDuplicateKeyChecker : public YAML::EventHandler(event-stream based because walking theYAML::Nodegraph expands self-referencing/nested aliases exponentially), tracks per-mapping key sets, normalizes null keys (~/null) to"null"to match reflect-cpp's reader (// The reflect step reads a null key as "null".), resolves scalar anchors/aliases, and rejects sequence/map/collection-alias keys (// The reflect step reads every key as a string, so a collection key never names a field.).src/config/Loader.cpp#L59-L68:try { rejectDuplicateKeys(content); } catch (const YAML::Exception&) { // Malformed YAML: the reflect step below reports it. } catch (const std::runtime_error& e) { throw std::runtime_error("Failed to parse config file '" + path + "': " + e.what()); } auto result = strict ? rfl::yaml::read<ParsedConfig, rfl::NoExtraFields>(content) : rfl::yaml::read<ParsedConfig>(content);
test/config/LoaderTest.cpp#L542-L650: 9 unit tests covering duplicate listener/service/nested keys,~vsnullkey collisions, scalar alias duplicates, self-referencing/fan-out anchors, and collection keys.
Root Cause in reflect-cpp
In include/rfl/yaml/Reader.hpp (read_object):
template <class ObjectReader>
std::optional<Error> read_object(const ObjectReader& _object_reader,
const InputObjectType& _obj) const noexcept {
for (const auto& p : _obj.node_) {
try {
const auto k = p.first.as<std::string>();
_object_reader.read(std::string_view(k), InputVarType(p.second));
} catch (std::exception& e) {
continue;
}
}
return std::nullopt;
}yaml-cpppreserves duplicate entries in aYAML::Nodemapping;read_objectfeeds each entry blindly into_object_reader.read(...), silently overwriting/ignoring duplicates even whenrfl::NoExtraFieldsis active.- When a mapping key is a sequence or map (non-scalar),
p.first.as<std::string>()throwsYAML::BadConversion, andcatch (std::exception& e) { continue; }silently drops the entire entry instead of returning anrfl::Error.
Suggested Direction / Fix
- In
rfl::yaml::Reader::read_object, return anrfl::Errorinstead of silentlycontinue-ing whenp.firstis not a scalar / cannot convert tostd::string(e.g., check!p.first.IsScalar()or propagate the conversion error). - Support duplicate-key rejection (either as a processor like
rfl::NoDuplicateKeysor as part of strict/YAML reader validation, usingYAML::EventHandleror per-mapping key tracking) so YAML config consumers don't have to parse documents twice with customyaml-cppevent handlers.
Metadata
Metadata
Assignees
Labels
known-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposwontfixThis will not be worked on
Activity
clockblocker commentedon Nov 29, 2026
Triage decision: closing the
rfl::NoDuplicateKeyscore-parser feature scope aswontfix(not planned) for the upstream adoption track.Rationale (
NoDuplicateKeys): Prototyped in fork PR #128, which scored 55/100 (below the>= 65cutline) due to deep core parser hooks, a 77-line hand-rolled FNV-1a hash table injson/Reader.hpp, an unapprovedReader-vs-ObjectReadercontract, andtoml++mismatches. PR #128 remains parked ondiscuss/ssot(see Draft PR #191 parked table).