fix(config): resolve dotted YAML paths to direct children only#680
Open
JSap0914 wants to merge 1 commit into
Open
fix(config): resolve dotted YAML paths to direct children only#680JSap0914 wants to merge 1 commit into
JSap0914 wants to merge 1 commit into
Conversation
getConfigValue reads via getYamlPath, whose walker reset its depth to the
matched-stack size on every line. When an intermediate segment of a dotted
path was not itself on the stack, the next segment matched at any deeper
indent, so:
- agent.service_tier matched a grandchild (agent.fallback.service_tier).
- a flat key like service_tier matched the first nested occurrence in any
block instead of resolving only at the top level.
The write path (setConfigValue via findYamlPath) already enforced
direct-child depth and column-0 flat keys; this aligns the read path with it.
Rewrite getYamlPath to walk one segment at a time, matching each segment only
among the direct children of its parent block (the shallowest indent inside
the block) and pinning single-segment keys to column 0.
Un-skips the three regression tests in config-value-paths.test.ts that
documented this gap.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates YAML path resolution strictness and enables previously skipped tests to verify correct dotted/flat-key behavior.
Changes:
- Enforces “direct-child only” matching for dotted paths in
getYamlPath - Pins flat (single-segment) keys to the top level and unskips corresponding tests
- Converts previously skipped tests into active assertions for grandchildren/nested occurrences
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/config-value-paths.test.ts | Unskips tests and documents intended strict YAML path behavior |
| src/main/yaml-path.ts | Reworks getYamlPath scanning to enforce direct-child depth and top-level-only flat keys |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+31
to
+37
| // Walk the path one segment at a time. `searchStart` is the first line to | ||
| // scan for the current segment; `parentIndent` bounds the parent's block — | ||
| // children live at indent strictly greater than it. The first segment uses | ||
| // parentIndent = -1, so only column-0 keys match (a flat/single-segment key | ||
| // is pinned to the top level and never resolves a nested occurrence). | ||
| let searchStart = 0; | ||
| let parentIndent = -1; |
| // without finding the next part), so reset pathIdx to the depth we are | ||
| // actually at — i.e. number of parts already matched in stack. | ||
| pathIdx = stack.length; | ||
| for (let p = 0; p < parts.length; p++) { |
Comment on lines
+47
to
+48
| let i = searchStart; | ||
| for (; i < lines.length; i++) { |
Contributor
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.
Bug
getConfigValuereads config.yaml throughgetYamlPath, but that walker is toopermissive on dotted paths. It reset its depth to the matched-stack size on every
line, so when an intermediate path segment wasn't itself on the stack, the next
segment matched at any deeper indent. Two concrete consequences:
agent.service_tierresolves a grandchild — e.g.agent.fallback.service_tier—instead of returning null when there is no direct
agent.service_tier.service_tiermatches the first nested occurrence in any block(e.g. under
telegram:oragent:) instead of resolving only at the top level.The write path (
setConfigValue→findYamlPath) already enforces direct-childdepth and pins single-segment keys to column 0; the read path didn't, so reads and
writes disagreed. This is the follow-up the repo's own
tests/config-value-paths.test.tsflagged with three
it.skipcases (originating from #247/#243).Fix
Rewrite
getYamlPathto walk one segment at a time and match each segment onlyamong the direct children of its parent block (the shallowest non-blank indent
inside that block), skipping deeper grandchildren. Single-segment paths use a
parent indent of -1, so only column-0 keys match. No behavior change for the
existing well-formed lookups; this only tightens the over-matching cases.
Un-skips the three regression tests that documented the desired strictness.
Verification
Before the fix the three un-skipped cases failed (e.g.
expected 'nested-deeper' to be null).After: Test Files 4 passed (4), Tests 53 passed (53).
eslint src/main/yaml-path.tsis clean.