Skip to content

fix: Encode ConfigApplyStatus query parameters - #4718

Merged
gmlewis merged 3 commits into
google:masterfrom
ktsoator:fix/ghes-config-apply-status-query
Nov 15, 2026
Merged

gmlewis merged 3 commits into
google:masterfrom
ktsoator:fix/ghes-config-apply-status-query

Conversation

@ktsoator

Copy link
Copy Markdown
Contributor

ConfigApplyStatus sends run_id in a JSON request body, but the GHES API defines it as a query parameter. Encode it in the URL and send an empty GET body, preserving the existing method signature and ConfigApply JSON behavior.

Validation: script/fmt.sh, script/test.sh, and script/lint.sh (including script/generate.sh --check). Regression tests cover ordinary and escaped run IDs, nil/empty options, and an empty GET body.

@ktsoator
ktsoator marked this pull request as ready for review November 14, 2026 05:51
@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Nov 14, 2026
@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.64%. Comparing base (a7255bb) to head (91ef32a).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
github/enterprise_manage_ghes_config.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4718      +/-   ##
==========================================
- Coverage   98.64%   98.64%   -0.01%     
==========================================
  Files         204      204              
  Lines       19154    19159       +5     
==========================================
+ Hits        18895    18899       +4     
- Misses        259      260       +1     

☔ 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.

Encode run_id with url.QueryEscape, preserving escaping and omission of
empty values while removing an unreachable addOptions error branch.
@ktsoator

ktsoator commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated to remove the unreachable error branch. Local coverage is now 100%; tests and lint pass. 🙂

@gmlewis

gmlewis commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Updated to remove the unreachable error branch. Local coverage is now 100%; tests and lint pass. 🙂

Actually, we have testBadOptions that will reach the previously-unreachable error branch, and I would prefer you revert to your previous version since that is more consistent with how the rest of the repo works and your current version would be an outlier as written.

@ktsoator

Copy link
Copy Markdown
Contributor Author

Updated to remove the unreachable error branch. Local coverage is now 100%; tests and lint pass. 🙂

Actually, we have testBadOptions that will reach the previously-unreachable error branch, and I would prefer you revert to your previous version since that is more consistent with how the rest of the repo works and your current version would be an outlier as written.

Thanks for the pointer!

I’ll switch back to addOptions and cover the error path with testBadOptions!

Use the shared query encoder for ConfigApplyStatus to match other
enterprise endpoints, retaining run_id query encoding and an empty GET
body.
@ktsoator

Copy link
Copy Markdown
Contributor Author

Hi, @gmlewis. Restored addOptions in 91ef32a for consistency.

I couldn’t trigger this error branch with testBadOptions, since the URL is fixed and run_id is escaped. I wondered if I was missing an existing approach, so I checked similar endpoints and found that ConfigApplyEvents also keeps the same error check with a fixed URL.

Tests and lint pass locally.

@gmlewis

gmlewis commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Ah, sorry I led you astray, but let's please keep this version and I'll investigate locally.

@ktsoator

ktsoator commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Ah, sorry I led you astray, but let's please keep this version and I'll investigate locally.

No worries at all! I’ve been using go-github in my Go projects, including some internal tooling at work, and really enjoy working with it. I’m glad to have a chance to contribute, and I’ll be happy to send more fixes if I run into other issues.

I’ll also keep looking into the patch coverage issue on my side and share anything useful I find. Thanks for taking the time to investigate!

@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, @ktsoator!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @Not-Dhananjay-Mishra

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra 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.
Just for your information, ConfigApplyOptions is also passed as the request body to ConfigApply. Since this may undergo a breaking change in the future, as it is passed by pointer, we can simply change the json tag to url tag at that time and get rid of the internal query building logic.

@ktsoator

Copy link
Copy Markdown
Contributor Author

LGTM. Just for your information, ConfigApplyOptions is also passed as the request body to ConfigApply. Since this may undergo a breaking change in the future, as it is passed by pointer, we can simply change the json tag to url tag at that time and get rid of the internal query building logic.

Thanks for the review! Makes sense to revisit this when ConfigApplyOptions gets refactored.

Happy to help with that or other fixes too. Feel free to point me to anything I could pick up! 🙂

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Nov 15, 2026
@gmlewis
gmlewis merged commit e15cdc4 into google:master Nov 15, 2026
14 of 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