Repository navigation
Conversation
`append` required an existing, non-empty sequence. Almost none of the lists it needs to reach are written until someone uses them: `routes`, `proxies`, `allow_from`, a key's `allow` are all optional, and the starting configuration is six lines. So **every "create the first one" in the UI failed at exactly the moment a new user reached for it** — the first route, the first proxy, the first CIDR in the allow list. End-to-end testing against a running gateway is what surfaced it; the unit tests all started from a file that already had the list. Three starting points now work, all producing block sequences: the key is absent, the key holds `[]`, or the key is there with nothing under it. ## Two positioning bugs, both caught by the self-check Neither reached disk — the re-parse guard rejected the result — but both would have been silent corruption without it. **The last child's byte range is not the last key's line.** A block sequence's value node starts at its first `-`, not at `key:`. Taking the indentation from there copies a list item's indentation, and the insertion point lands *inside* the list: appending `routes` to a config whose last key was `clients` wrote `routes:` between two clients. The block is now measured across every node under the parent, and the indentation is the smallest one in that block. **A map that is itself a list entry keeps its first key on the dash line.** ` - name: a` indents two, while the keys live at four, so the smallest indentation in the block is two and the new key lands outside the entry. Lines starting with `-` are excluded from that measurement, falling back to dash + 2 when the entry is a single line. Four tests, one per path that a first-time user actually walks: a key that is not in the file, `[]` becoming a block list, comments surviving the creation of a new key, and a nested key (`clients[].allow`) that does not exist yet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The gap
appendrequired an existing, non-empty sequence. Almost none of the lists it needs to reach are written until someone uses them —routes,proxies,allow_from, a key'salloware all optional, and the starting configuration is six lines.So every "create the first one" in the UI failed at exactly the moment a new user reached for it: the first route, the first proxy, the first CIDR in the allow list.
End-to-end testing against a running gateway is what surfaced this. The unit tests all started from a file that already had the list — which is the one shape a new user never has.
Three starting points work now, all producing block sequences: the key is absent, the key holds
[], or the key is present with nothing under it.Two positioning bugs, both caught by the self-check
Neither reached disk — the re-parse guard rejected the result — but both would have been silent corruption without it.
The last child's byte range is not the last key's line. A block sequence's value node starts at its first
-, not atkey:. Taking indentation from there copies a list item's indentation, and the insertion point lands inside the list: appendingroutesto a config whose last key wasclientswroteroutes:between two clients.The block is now measured across every node under the parent, and the indentation is the smallest one in that block.
A map that is itself a list entry keeps its first key on the dash line.
- name: aindents two while the keys live at four, so the smallest indentation in the block is two and the new key lands outside the entry. Lines starting with-are excluded from that measurement, falling back to dash + 2 when the entry is a single line.Tests
Four, one per path a first-time user actually walks: a key that is not in the file,
[]becoming a block list, comments surviving the creation of a new key, and a nested key (clients[].allow) that does not exist yet.Verification
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, 1092 tests, andscripts/smoke.sh— 46 checks, 0 failures.🤖 Generated with Claude Code