Repository navigation
fix(yaml): return error on non-scalar mapping keys instead of silently skipping - #219
Open
clockblocker wants to merge 1 commit into
Open
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
…y skipping Parent: munich-data-engineering#801 (`yaml::Reader::read_object` recursive alias guard). `rfl::yaml::Reader::read_object` previously wrapped `p.first.as<std::string>()` and `_object_reader.read(...)` in `catch (std::exception& e) { continue; }`, silently dropping mapping entries whose keys were sequences, maps, or aliases to collections (e.g. `[1, 2]: foo` or `{a: 1}: bar`). This caused silent data loss in maps / `rfl::Generic` and silently bypassed `rfl::NoExtraFields`. Validate the mapping key inside the `try` block and return an explicit `rfl::Error` ("YAML mapping key must be a scalar.") whenever a key is neither a scalar nor YAML null, propagating any `yaml-cpp` exception as an `rfl::Error` instead of skipping. Move `_object_reader.read(...)` outside the `try` block (matching all other structured readers) and pass a zero-copy `std::string_view` directly from `p.first.Scalar()` (or `"null"` for YAML null keys `~` / `null` / empty `: val`). Scalar aliases and merge keys (`<<`) continue to work identically. Addresses downstream workaround in `openmoq/moqx` (`src/config/YamlDuplicateKeys.cpp:23-111`, `test/config/LoaderTest.cpp:542-650`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Reading a YAML mapping caught key-conversion exceptions with
continue, silently dropping entries whose keys were sequences, maps, or collection aliases.That caused silent data loss in maps and
rfl::Generic, and let malformed keys bypassrfl::NoExtraFields.Summary
<<), and YAML null keys (null,~,: val).std::string_viewkeys fromScalar()instead of allocating per key; stacks on PR #801.Consumer Impact
openmoq/moqxYamlDuplicateKeys.cpp#L23-L111YAML::EventHandlerpre-pass to reject non-scalar keys beforerfl::yaml::read.For Agents
upstream-queue(6fc44d73) · Score88/100(S=29,M=24,D=22,R=13) ·+11/-4(1f)queue-tests/yaml/test_non_scalar_keys.cpp