Fix sub-table of a dotted key escaping its parent header path (#557)#568
Open
earfman wants to merge 3 commits into
Open
Fix sub-table of a dotted key escaping its parent header path (#557)#568earfman wants to merge 3 commits into
earfman wants to merge 3 commits into
Conversation
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.
Fixes #557.
Problem
Assigning a sub-table under a dotted-key super-table nested inside a real table caused the sub-table header to lose its parent path on render:
parse(dumps(doc)) != doc, so this is a round-trip / data-loss bug. The same happened inside array-of-tables elements ([[servers]]produced[a.c]instead of[servers.a.c]).Cause
In
Container._render_table,prefixserved two purposes at once: the relative dotted-key prefix used for leaf items (soa.bstays inline under[t]) and the absolute header path used for nested sub-tables (which need[t.a.c]). The "dotted key inside table" branch dropped the prefix entirely — right for the leaf, wrong for a real sub-table nested underneath, which then lost thet.parent path._render_aot_tablehad the same issue.Fix
Track the absolute header path separately via a new
header_prefixargument. Leaf items continue to render off the relative key; nested sub-table and array-of-tables headers render off the absolute path. When a table carries adisplay_name(from a parsed explicit header) the two paths coincide, so existing output is unchanged.Tests
Added regression tests covering the table case, a chained dotted parent (
a.b.x— the leaf stays relative while the sub-table header is absolute), and the array-of-tables case. The full suite passes (1053 tests).Found and fixed with an integrity-first pipeline; the fix was independently verified by a separate agent than the one that found it before submission.