load_yaml: Fix dropped inplace-link siblings
A jw.inplace-link node deep-merges its sibling keys into the resolved target. When the target resolves to a non-dict value, the merge is skipped and the sibling keys are silently discarded, losing document data without any warning. Raise ValueError when the resolved target is not a mapping and the node carries sibling keys, and add regression tests for scalar and list targets. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
2bd1db5d90
commit
b3a3fc0507
1 changed files with 29 additions and 4 deletions
|
|
@ -225,10 +225,15 @@ def _expand_links_recursive(
|
|||
value, root, current_path + (key, ), resolved, resolving
|
||||
)
|
||||
|
||||
if not expanded_remaining:
|
||||
return base_value
|
||||
if not isinstance(base_value, dict):
|
||||
raise ValueError(
|
||||
f'jw.inplace-link {link_spec!r}: resolved value is not '
|
||||
f'a mapping, cannot merge siblings'
|
||||
)
|
||||
# Deep-merge siblings into resolved dict (siblings win on conflict)
|
||||
if isinstance(base_value, dict) and expanded_remaining:
|
||||
return _deep_merge(base_value, expanded_remaining)
|
||||
return base_value
|
||||
return _deep_merge(base_value, expanded_remaining)
|
||||
|
||||
# --- jw.link (sole key): inplace or named replacement ---
|
||||
if 'jw.link' in node and len(node) == 1:
|
||||
|
|
|
|||
Loading…
Reference in a new issue