Repository navigation
fix: Escape workflow file names in URL paths - #4753
Merged
Merged
Conversation
The six *ByFileName methods in ActionsService put the workflow file name into the URL path unescaped. A name containing # is cut off at the fragment, and a percent-escape in a name is sent as is and decoded by the server, so the request fails or reaches the wrong workflow. Escape the name with url.PathEscape, as google#4536, google#4546 and google#4750 did for other path parameters.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4753 +/- ##
=======================================
Coverage 98.63% 98.63%
=======================================
Files 204 204
Lines 19165 19165
=======================================
Hits 18904 18904
Misses 261 261 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gmlewis
approved these changes
Dec 1, 2026
gmlewis
left a comment
Collaborator
There was a problem hiding this comment.
Thank you, @AnujYamdagni!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
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 six
*ByFileNamemethods inActionsServiceput the workflow file name into the URL path without escaping it. A name containing#is cut off at the fragment:GetWorkflowByFileName(ctx, "o", "r", "ci#1.yml")sendsGET /repos/o/r/actions/workflows/ci, which returns 404 unless the truncated name happens to match another workflow. A name containing a percent-escape is sent as is, soci%231.ymlis requested asci#1.yml. The usage, dispatch, enable, disable and list-runs methods have the same problem.This change escapes the name with
url.PathEscapein all six methods, as #4536, #4546 and #4750 did for other path parameters, and adds the "URL path escaped for you" note to each method's docs. A caller who already escapes the name (passingci%231.yml) now sends it double-escaped, which matches how the other escaped parameters behave.Test plan (Go 1.27.4, linux/amd64, master at 19d05c4):
go test -count=1 -run 'workflowFileName_isEscaped|ListWorkflowRunsByFileName_isEscaped' ./github/: on master, 12 of the 24 new subtests fail (theci#1.ymlandci%231.ymlcases for each method); with this change all 24 pass.go test -count=1 ./github/: ok.Not tested: requests against the live GitHub API.
AI assistance: an AI tool found the missing escapes and drafted the change, the tests and this description. I reviewed the diff and the test results.