Skip to content

fix: Escape branch names when listing rules - #4534

Merged
gmlewis merged 1 commit into
google:masterfrom
nickita-khylkouski:fix/list-rules-branch-escape
Sep 10, 2026
Merged

fix: Escape branch names when listing rules#4534
gmlewis merged 1 commit into
google:masterfrom
nickita-khylkouski:fix/list-rules-branch-escape

Conversation

@nickita-khylkouski

Copy link
Copy Markdown
Contributor

hey, ListRulesForBranch puts the branch name straight into the URL, so a valid name like fix/#123-login gets truncated at #. literal % characters can also change the name or make URL parsing fail. this uses url.PathEscape(branch), like the other branch methods and #2948. added regression tests in repos_rules_test.go for ordinary names, slashes, #, and literal %, with and without pagination. BREAKING CHANGE: callers that already escape names as a workaround need to pass the raw branch name instead. this also applies to ListRulesForBranchIter. AI-assisted: ChatGPT helped investigate and draft the fix/tests. the isolated regression checks fail before the fix and pass after; full Go 1.26 repository checks are still pending.

@gmlewis gmlewis changed the title fix!: Escape branch names when listing rules fix: Escape branch names when listing rules Sep 10, 2026
@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Sep 10, 2026
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.53%. Comparing base (4340312) to head (81b25d7).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4534   +/-   ##
=======================================
  Coverage   98.53%   98.53%           
=======================================
  Files         195      195           
  Lines       17851    17851           
=======================================
  Hits        17590    17590           
  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, @nickita-khylkouski!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @Not-Dhananjay-Mishra

Note that I removed the "!" from "fix!:" since you are not technically breaking the API, although you will be breaking users you already escape the branch name... so we will leave the "BREAKING CHANGE" in the description, but we won't call it out as a breaking API change. I hope that makes sense.

@gmlewis

gmlewis commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Thank you, @alexandear!
Merging.

@gmlewis
gmlewis merged commit 9ef86bf into google:master Sep 10, 2026
15 checks passed
@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Sep 10, 2026
prasanna8585 added a commit to prasanna8585/go-github that referenced this pull request Sep 11, 2026
Addresses gmlewis's review: all 23 modified methods across the 5 files
touched by this PR now explicitly state, in their doc comment, that the
environment name is URL path escaped for the caller -- matching the
exact wording and placement already used for the branch parameter in
ListRulesForBranch (PR google#4534):

  // Note: the environment name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .

Placed directly after each method's one-line summary and before its
"GitHub API docs:" line, consistent with the branch-name precedent.

No logic changed -- doc comments only.
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