Skip to content

[BUG]: Updating GitHub Pages Fails in GHES #2087

Closed

Description

@sstrullmyer

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 apply on the above Terraform configuration file targeting a GitHub Enterprise Server instance via GITHUB_BASE_URL (or equivalent provider configuration)
  • Change build_type to "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

Activity

  1. added
    Status: Triage
    Type: Bug
    on Jan 9, 2024
  2. added
    Status: Up for grabs
    and removed
    Status: Triage
    on Jan 18, 2024
  3. moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Activeon Jan 18, 2024
  4. Sam13 commented on Sep 6, 2024

    @Sam13

    Same issue here with GHES v3.13.2.

    Any better workarounds than ignoring the pages configuration in the repository resource?

    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.

    @sstrullmyer Yes please

  5. github-actions commented on Jun 4, 2025

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  6. added
    Status: Stale
    on Jun 4, 2025
  7. moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Activeon Jun 11, 2025
  8. Sam13 commented on Jun 24, 2025

    @Sam13

    Still useful - not done - please reopen

  9. tobias-jenkner commented on Jan 26, 2026

    @tobias-jenkner

    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?

  10. reopened this on Jan 26, 2026
  11. 9 remaining items

  12. tobias-jenkner-ecc commented on Feb 11, 2026

    @tobias-jenkner-ecc

    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?

    @tobias-jenkner Could you provide a config example of what is failing and DEBUG logs of apply to help us pinpoint the issue with the latest provider version? Which GHES version are you on?

    We use GHES version 3.17. I will create config example to reproduce this.

  13. tobias-jenkner-ecc commented on Feb 11, 2026

    @tobias-jenkner-ecc

    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?

    @tobias-jenkner Could you provide a config example of what is failing and DEBUG logs of apply to help us pinpoint the issue with the latest provider version? Which GHES version are you on?

    We use GHES version 3.17. I will create config example to reproduce this.

    Testcase:

    resource "github_repository" "repo" {
      name   = "test-gh-pages-2087"
    
      visibility = "private"
    
      # create the default branch for new repos
      auto_init = true
    
      pages {
        # apply / create repository with build_type = "legacy" first 
        build_type = "legacy"
        # switch to / apply with build_type = "workflow" to trigger the issue - "400 Custom domains are not available for GitHub Pages []" 
        # build_type = "workflow"
      }
    }
    

    legacy.log
    workflow.log containing the error message

  14. tobias-jenkner-ecc commented on Feb 11, 2026

    @tobias-jenkner-ecc

    @deiga Is this sufficient? Are you able to reproduce this?

  15. deiga commented on Feb 11, 2026

    @deiga
    Collaborator

    @deiga Is this sufficient? Are you able to reproduce this?

    I'll try, thanks!

  16. self-assigned this
    on Feb 11, 2026
  17. deiga commented on Feb 11, 2026

    @deiga
    Collaborator

    @tobias-jenkner I think I might have something.
    This line will return an empty string if cname is null in the API response (which it is).

    Now we save it into state as "" and the PagesUpdate object doesn't have omitempty in the JSON marshalling instructions (because deleting a CNAME works only with sending null).
    So, now we are trying to send "" as the CNAME which would of course fail, since your instance disallows Custom domains!

  18. tobias-jenkner-ecc commented on Feb 18, 2026

    @tobias-jenkner-ecc

    @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?

  19. added this to the v6.12.0 milestone on Apr 18, 2026
  20. modified the milestones: v6.12.0, v6.13.0 on Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Awaiting responseStatus: Up for grabsType: Bugr/repository

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions