fix(yaml): stop retrying an unrecoverable decode error in condition - #10238
Merged
olblak merged 2 commits intoSep 4, 2026
Merged
Conversation
yaml.v3 does not advance past a syntax error, so a file whose first document parses and whose remainder does not makes Decode return the same non-EOF error on every call. The yamlpath engine appended an error and continued, spinning until the process was OOM-killed. A heap profile of an org-wide autodiscovery run showed 11.16GB of 14.71GB held in fmt.Errorf under (*Yaml).Condition. The trigger was a Markdown file sitting in a .github/workflows directory: its first document parses as a scalar, the rest yields a sticky "did not find expected <document start>". Stop reading the file instead, which is what source.go and target_yamlpath.go already do for the same error. Also wrap derr rather than err, which was nil at that point and hid the real cause. Signed-off-by: Loïs Postula <lois@mbrella.eu>
olblak
approved these changes
Sep 4, 2026
olblak
enabled auto-merge (squash)
September 4, 2026 11:09
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 yamlpath engine retries a decode error it cannot recover from, so a single
unparseable file makes
Conditionallocate until the process is OOM-killed.yaml.v3does not advance past a syntax error: onceDecodefails, everysubsequent call returns the same non-EOF error. The loop appends an error and
continues, so it spins forever:A heap profile of an org-wide GitHub Action autodiscovery run (45 repositories
via a
githubsearchscm) shows where it goes:The trigger in our case was a Markdown file sitting in a
.github/workflowsdirectory. Its first document parses as a scalar; the remainder then yields a
sticky
yaml: line 8: did not find expected <document start>. Any file thatparses partially will do it.
This stops reading the file on such an error, which is what
source.goandtarget_yamlpath.goalready do for the same case —condition.gowas the onlyone retrying. It also wraps
derrrather thanerr, which is nil at thatpoint, so the message reported
%!w(<nil>)instead of the parse failure.Test
Test_Condition_yamlpathUndecodableFilefails (10s guard, "the decoder loop isspinning on a non-EOF error") with
continuerestored, and passes withbreak.Verified against the real workload that surfaced it — same policy set, same 45
repositories: 15.4 GB peak, dying after 13 repositories → 886 MB peak across
547 pipelines.
Additional Information
Checklist
Tradeoff
Stopping at the first undecodable document means later documents in that file
are not inspected. They are unreachable anyway: the decoder cannot get past the
syntax error, so the previous behaviour never reached them either — it just
spun. The condition still reports the file as failing.
Potential improvement
derr == io.EOFcould beerrors.Is(derr, io.EOF)here and in the two siblingfiles. Left alone to keep this diff to the bug.