Repository navigation
Description
Expected Behavior
Hello,
I have been encountering an issue making modifications to the pages block of github_repository resources in GitHub Enterprise Server (3.10.3).
I am able to initially create a github_repository resource with a pages block, such as this:
resource "github_repository" "main" {
name = "terraform-provider-github-pages-test"
pages {
build_type = "legacy"
source {
branch = "main"
path = "/"
}
}
}I expect that changing an argument, such as build_type, would result in the GitHub repository's configuration successfully being modified in GHES. An example valid, new Terraform configuration could be
resource "github_repository" "main" {
name = "terraform-provider-github-pages-test"
pages {
build_type = "workflow"
source {
branch = "main"
path = "/"
}
}
}Actual Behavior
The Terraform provider attempts to update the GitHub Pages configuration, but fails with a 400 error:
│ Error: PUT https://<base_url>/api/v3/repos/SStrullmyer/terraform-provider-github-pages-test/pages: 400 Custom domains are not available for GitHub Pages []
│
│ with github_repository.main,
│ on main.tf line 1, in resource "github_repository" "main":
│ 1: resource "github_repository" "main" {
This results in the desired configuration not being effected. This is doubly problematic, as the tfstate associated with this block appears to be prematurely updated, anticipating a successful PUT; coupled with #1913, this can lead to additional challenges.
I've tested calling the /api/v3/repos/.../pages endpoint directly (outside of Terraform contexts), and can confirm that a PUT request that includes any cname entry, including empty strings and null, results in the same 400 error message.
I suspect all that would be required here would be to not provide the cname argument to the */pages endpoint if the GITHUB_BASE_URL indicates the target is a GHES instance. If this path (or another) is amenable, I'd be happy to pursue a PR for it.
Terraform Version
Terraform v1.6.6 on windows_amd64 + provider registry.terraform.io/integrations/github v5.43.0
Affected Resource(s)
- github_repository
Terraform Configuration Files
resource "github_repository" "main" {
name = "terraform-provider-github-pages-test"
pages {
build_type = "legacy"
source {
branch = "main"
path = "/"
}
}
}Steps to Reproduce
- Run
terraform applyon the above Terraform configuration file targeting a GitHub Enterprise Server instance via GITHUB_BASE_URL (or equivalent provider configuration) - Change
build_typeto"workflow" - Run
terraform apply
Debug Output
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: PUT /api/v3/repos/SStrullmyer/terraform-provider-github-pages-test/pages HTTP/1.1
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: User-Agent: go-github/v55.0.0
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: Content-Length: 39
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: Accept: application/vnd.github.v3+json,application/vnd.github.stone-crop-preview+json
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: Content-Type: application/json
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: X-Github-Api-Version: 2022-11-28
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: Accept-Encoding: gzip
[DEBUG] provider.terraform-provider-github_v5.43.0.exe
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: {
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: "cname": null,
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: "build_type": "workflow"
[DEBUG] provider.terraform-provider-github_v5.43.0.exe: }Panic Output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
Sam13 commentedon Sep 6, 2024
Same issue here with GHES v3.13.2.
Any better workarounds than ignoring the pages configuration in the repository resource?
@sstrullmyer Yes please
github-actions commentedon Jun 4, 2025
👋 Hey Friends, this issue has been automatically marked as
stalebecause it has no recent activity. It will be closed if no further activity occurs. Please add theStatus: Pinnedlabel if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!Sam13 commentedon Jun 24, 2025
Still useful - not done - please reopen
tobias-jenkner commentedon Jan 26, 2026
I hoped that this would be fixed with #2778, but unfortunately with version 6.10.2 I still get this error:
400 Custom domains are not available for GitHub Pages []Any chance to reopen this again now?
9 remaining items
tobias-jenkner-ecc commentedon Feb 11, 2026
We use GHES version 3.17. I will create config example to reproduce this.
tobias-jenkner-ecc commentedon Feb 11, 2026
Testcase:
legacy.log
workflow.log containing the error message
tobias-jenkner-ecc commentedon Feb 11, 2026
@deiga Is this sufficient? Are you able to reproduce this?
deiga commentedon Feb 11, 2026
I'll try, thanks!
deiga commentedon Feb 11, 2026
@tobias-jenkner I think I might have something.
This line will return an empty string if
cnameisnullin the API response (which it is).Now we save it into state as
""and thePagesUpdateobject doesn't haveomitemptyin the JSON marshalling instructions (because deleting a CNAME works only with sendingnull).So, now we are trying to send
""as the CNAME which would of course fail, since your instance disallows Custom domains!copilot generated testcase for integrations#2087
copilot generated testcase for integrations#2087
tobias-jenkner-ecc commentedon Feb 18, 2026
@deiga I tried to create a fix: #3207 (FYI: since I only have little go knowledge so I relied heavily on Copilot). I tried to create a more generic and streamlined solution - maybe you can comment and give me some hints?