Repository navigation
fix(yaml): preserve line numbers after header preprocessing - #2939
Merged
Merged
Conversation
Owner
|
@mikefarah Triage: this looks like a popular PR. 5 distinct outside users (all on #1956, raised by martincostello): wrong line numbers reported for YAML docs with headers/directives; breaks error locations in tooling. |
gabrielcosi
pushed a commit
to gabrielcosi/home-ops
that referenced
this pull request
Nov 6, 2026
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [mikefarah/yq](https://mikefarah.gitbook.io/yq/) ([source](https://github.com/mikefarah/yq)) | patch | `4.54.1` → `4.54.2` | --- ### Release Notes <details> <summary>mikefarah/yq</summary> ### [`v4.54.2`](https://github.com/mikefarah/yq/releases/tag/v4.54.2) [Compare Source](mikefarah/yq@v4.54.1...v4.54.2) - Fixed command injection risk in shell output with `-o=shell -r`: unsafe values are now quoted and a warning is logged. Use `--security-force-never-escape-shell-output` to restore the previous unsafe behaviour (GHSA-h2cv-65fq-jgrp) - Fixed YAML structure being changed when assigning head comments ([#​2847](mikefarah/yq#2847)) Thanks [@​rootsec1](https://github.com/rootsec1) - Fixed `ireduce` to run per pipeline input, matching jq's `reduce` behaviour ([#​2869](mikefarah/yq#2869)) Thanks [@​00200200](https://github.com/00200200) - Fixed `map_values` to remove entries when the expression returns nothing ([#​2862](mikefarah/yq#2862)) Thanks [@​yuefdev](https://github.com/yuefdev) - Fixed preservation of comments on TOML inline table values ([#​2879](mikefarah/yq#2879)) Thanks [@​iamhuman-cheolheelee](https://github.com/iamhuman-cheolheelee) - Fixed INI keys containing colons ([#​2886](mikefarah/yq#2886)) - Fixed YAML line numbers after header preprocessing ([#​2939](mikefarah/yq#2939)) Thanks [@​imharjot](https://github.com/imharjot) - Fixed an extra leading comment blank line with CRLF input ([#​2856](mikefarah/yq#2856)) Thanks [@​cestercian](https://github.com/cestercian) - Cleaned up failed in-place edits ([#​2920](mikefarah/yq#2920)) Thanks [@​Boulea7](https://github.com/Boulea7) - Bumped dependencies </details> --- ### Configuration 📅 **Schedule**: (in timezone Europe/Berlin) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xOTguMyIsInVwZGF0ZWRJblZlciI6IjQ0LjE5OC4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.xcd.dev/gabrielcosi/home-ops/pulls/1604
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 #1956.
Header preprocessing removes comments, blank lines and separators before YAML decoding, so
linereports positions relative to the remaining input. The reported.foo.bar | lineexample returns2instead of4.Keep those consumed lines as blank parser input while retaining the original header for output. Also keep the newline when reinserting content after an inline
---, so an inline comment cannot swallow the following line.Regressions cover LF/CRLF headers, keys and values, later documents, decoder reuse, inline separators, and comment/content preservation. They fail with the original decoder. The built CLI reproduces the before/after results.
Validation on macOS arm64: the focused line/YAML tests, alternate
GOCCY=trueline tests, formatting, spelling, gosec, lint, build, Go-install compatibility and acceptance tests pass.The full unit suite has one pre-existing failure:
TestJSONScenariosexpectsjson: string of object unexpected end of JSON input, but getsinvalid character 'b' after object key:value pair. Unchangedmasterand this patch fail identically on Go 1.26.4 and 1.27.1 (the development-container pin). No assertions were changed.make local buildexits successfully becausescripts/test.shcontinues after the failinggo test; I also rango test ./...directly to check this.