Skip to content

fix: Escape workflow file names in URL paths - #4753

Merged
gmlewis merged 1 commit into
google:masterfrom
AnujYamdagni:fix/workflow-file-name-escape
Dec 1, 2026
Merged

gmlewis merged 1 commit into
google:masterfrom
AnujYamdagni:fix/workflow-file-name-escape

Conversation

@AnujYamdagni

Copy link
Copy Markdown
Contributor

The six *ByFileName methods in ActionsService put 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") sends GET /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, so ci%231.yml is requested as ci#1.yml. The usage, dispatch, enable, disable and list-runs methods have the same problem.

This change escapes the name with url.PathEscape in 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 (passing ci%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 (the ci#1.yml and ci%231.yml cases 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.

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.
@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Dec 1, 2026
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.63%. Comparing base (19d05c4) to head (fce4e12).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @AnujYamdagni!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @Not-Dhananjay-Mishra

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Dec 1, 2026
@gmlewis
gmlewis merged commit db78161 into google:master Dec 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants