Repository navigation
Don't apply an action's sub-path rewrite to reusable workflow calls - #263
Merged
nodeselector merged 2 commits intoNov 5, 2026
Merged
Conversation
subpathRewriteLookup mapped any owner/repo/<path>@ref onto an owner/repo@ref rewrite, including owner/repo/.github/workflows/<file>@ref. When a step used an action from the same repository pinned by the same SHA, fix mode rewrote the reusable workflow call to the tag as well, although the lockfile doesn't lock reusable workflow calls. Skip values that parserlock.ParseActionRef doesn't parse as an action. Fixes github#261 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check replacements for the owner/repo@ref key before running parserlock.ParseActionRef, so values without a matching rewrite skip the full validation. Drop the inline comment that repeated, too narrowly, what LookupRewrite's doc comment says, and the nested workflow file test case, which only exercised ParseActionRef. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change preserving reusable workflow commit-SHA pins during action sub-path rewrites.
No open issues 🎉
What changed in this PR
Fixes #261 by preventing action sub-path rewrites from changing reusable workflow calls. This preserves their commit-SHA pins while reusable workflows remain outside lockfile coverage.
Changes:
- Restricts fallback matching to values parsed as action references, leaving exact-key matching unchanged.
- Documents the exact-key assumption and adds regression tests for preserved workflow refs, action rewrites, and required-rewrite counts.
| File | Description |
|---|---|
internal/workflowfile/rewrite.go |
Guards fallback matching and documents exact-key behavior. |
internal/workflowfile/rewrite_test.go |
Tests workflow-call preservation, supported action paths, and rewrite counts. |
Review effort: Max (auto)
nodeselector
approved these changes
Nov 5, 2026
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 #261
Cause
RewriteActionRefslooks up everyuses:value withLookupRewrite. When there is no exact key,subpathRewriteLookupmapsowner/repo/<path>@refonto anowner/repo@refrewrite and replaces the ref.Some planners key rewrites by
owner/repo@refwithout the sub-path:reverseLookupRewrites,narrowDirectDeps, and the semver branch ofnarrowVerifiedEntries. So when a step uses an action from the same repository (e.g.owner/repo/restore@<sha>), the reusable workflow callowner/repo/.github/workflows/x.yml@<sha>matches the same key and is rewritten to the tag too.The lockfile doesn't lock reusable workflow calls, so the full commit SHA is the only pin they have.
Change
subpathRewriteLookupnow returns no match for values thatparserlock.ParseActionRefdoesn't parse as an action.ParseActionRefreturns nil for any YAML file under.github/workflows/. The rest of the lookup is unchanged, and so are sub-path actions such asowner/repo/restore@refandowner/repo/.github/actions/foo@ref.The exact-key path is left as it is: no planner keys a rewrite by a reusable workflow call today. I added a note to the
LookupRewritedoc comment so this assumption isn't lost if reusable workflow calls get locked (#179).This also changes
ValidateRequiredActionRefRewrites. Before, a reusable workflow call matched through the sub-path fallback was counted inchangedbut not inmatches, so a required rewrite failed with "required action rewrite matched 1uses:values but could update only 2".Tests
TestSubpathRewriteLookup: a reusable workflow call and a nested workflow file don't match; a non-workflow path under.github/still matches.TestRewriteActionRefs_SkipsReusableWorkflowCalls: the reproduction from Fix mode unpins a reusable workflow call when the same repository is also used as a step action #261 keeps the reusable workflow call's ref and comment, and a workflow-shaped value underwith:keeps its value.TestValidateRequiredActionRefRewrites(new): a reusable workflow call next to a step from the same repository isn't counted as a rewrite.All of these except the non-workflow path case fail without the change.
make test,make fmt-checkandmake vetpass.I also ran the reproduction from #261 with the built binary: the step is rewritten to
@v0.0.10, the reusable workflow call keeps its SHA and comment,--no-fixreports "All 1 workflow valid", and a second run doesn't change anything.Related issues not fixed here
This is a narrow fix inside the fallback. I found these while reading the code; I haven't reproduced them.
RewriteActionRefs,ValidateRequiredActionRefRewritesandUsesValuesvisit every key nameduses, whilewalkUsesonly visits step and job positions. An action-shapedwith: { uses: owner/repo/restore@<sha> }is still rewritten by a step action's rewrite.subpathRewriteLookupkeeps the oldowner/repoand replaces only the ref. A redirect rewrite fromtransferRewrites(old/repo@<sha>->new/repo@v1) can turnold/repo/sub@<sha>intoold/repo/sub@v1, a ref that may not exist on the old repository.ValidateRequiredActionRefRewritescan then also report a count mismatch.narrowVerifiedEntries,transferRewrites) use the full name. Keying every rewrite by the fulluses:value would make the fallback unnecessary, but cases where the workflow has no matchinguses:(e.g.$/…action files) need checking first.🤖 Generated with Claude Code