-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Resolve '400 Custom domains' error on GitHub Enterprise Server #3489
Conversation
The UpdatePages method fails on GitHub Enterprise Server. The fix set nil CNAME when request sending to GHES. References: - Issue: google#3466 Signed-off-by: atilsensalduz <atil.sensalduz@gmail.com>
The UpdatePages method fails on GitHub Enterprise Server. The fix set nil CNAME when request sending to GHES. References: - Issue: google#3466 Signed-off-by: atilsensalduz <atil.sensalduz@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3489 +/- ##
=======================================
Coverage 91.02% 91.03%
=======================================
Files 179 179
Lines 15561 15574 +13
=======================================
+ Hits 14165 14178 +13
Misses 1223 1223
Partials 173 173 ☔ View full report in Codecov by Sentry. |
What happens when a person wishes to remove a custom domain? When this happens for other endpoints (where sending a "null" is important and has a specific meaning), we often introduce a second endpoint that has serves the other usage, and whose name highlights the difference between the two use cases. I think that might be appropriate here. If you look around, you should be able to find some endpoints like that, but if you can't, let me know and I'll dig around for examples of this. |
The UpdatePages method was failing on GHES due to the CNAME field being sent in the request. This fix introduces a dedicated method for updating pages on GHES, using a request struct without the CNAME field to ensure compatibility. References: - Issue: google#3466 Signed-off-by: atilsensalduz <atil.sensalduz@gmail.com>
The UpdatePages method was failing on GHES due to the CNAME field being sent in the request. This fix introduces a dedicated method for updating pages on GHES, using a request struct without the CNAME field to ensure compatibility. References: - Issue: google#3466 Signed-off-by: atilsensalduz <atil.sensalduz@gmail.com>
You're absolutely right. Thanks for guiding me toward the better approach. I've updated the PR to use a separate endpoint for updating pages specifically for GHES and to use a struct without the CNAME field to avoid the 400 error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @atilsensalduz!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
@stevehipwell - might you have time for a coffee review? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whups, I spoke too soon. Please fix the lint issues by following step 4 of CONTRIBUTING.md.
The UpdatePages method was failing on GHES due to the CNAME field being sent in the request. This fix introduces a dedicated method for updating pages on GHES, using a request struct without the CNAME field to ensure compatibility. References: - Issue: google#3466 Signed-off-by: atilsensalduz <atil.sensalduz@gmail.com>
Ah, sorry about that! I must have missed it. 🤦 Thanks for the heads-up! I've fixed the lint issues now. I really appreciate your review and support! @gmlewis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you, @stevehipwell! |
This PR fixes an issue with the UpdatePages method, which caused the error: "400 Custom domains are not available for GitHub Pages" on GHES. The issue occurred because the update struct didn't specify the omitempty tag for JSON marshalling, which resulted in explicit null values being sent. As a result, GHES returned the error.
To resolve this, the fix adds a check for the client URL. If the URL differs from the public GitHub API, a new struct is created without the CNAME field to avoid sending null values.
Question: Should we add the omitempty tag directly to the CNAME field of the PagesUpdate struct instead of this workaround?
References:
Fixes: #3466.