Key-aware YAML replacement may match wrong key at different nesting levels
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reading extractKeyFromPath and the key-aware YAML replacement introduced in #22. Reproduce the metadata.version/spec.version scenario, then choose an approach that targets the requested path without matching the same key at another nesting level; done means the intended occurrence alone is replaced.
Written by the indexing model from the issue text.
Description
Summary
The key-aware YAML replacement introduced in #22 extracts only the final key name from a path (e.g., metadata.version → version). This works well for distinguishing between different keys like version and appVersion, but could match the wrong occurrence when the same key name exists at different nesting levels.
Scenario
Given a YAML file:
metadata:
version: 0.9.0
spec:
version: 0.9.0
If we want to update metadata.version, the current implementation generates a pattern like version:\s*0\.9\.0 which would match both occurrences. The first match would be replaced, which may or may not be the intended one depending on file structure.
Current Behavior
extractKeyFromPath("metadata.version") returns "version", losing the parent context.
Potential Solutions
- Line-number aware replacement - Use the YAML library to find the exact line number of the target path, then only replace on that specific line
- Full path matching - For nested paths, include parent keys in the pattern (though this gets complex with varying indentation)
- YAML AST modification - Parse, modify, and re-serialize the YAML (would lose formatting/comments)
Impact
This is likely a low-priority edge case since:
- Most version files (Chart.yaml, package.json) don't have duplicate key names at different levels
- The common case (
versionvsappVersion) is now handled correctly
Related
- Fixed in #22 for the
version/appVersioncase
🤖 Generated with Claude Code
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stacklok/releaseo
-
enhancement security
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Dependency Dashboard Open
Difficulty 2/5 1-3 hours Newbie friendliness 20/100
-
documentation security
Difficulty 1/5 1-3 hours Newbie friendliness 55/100
All issues in stacklok/releaseo
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100