Skip to content

[BUG]: github_organization_settings resource fails with HTTP 422 #2305

Closed

Description

@giuliov-unum

Expected Behavior

We want to use the GitHub Terraform provider to manage our organizations but the github_organization_settings resource invariably fails with HTTP 422.

Tried many different combinations with no luck:

  • an existing Org manually created referred via data
  • an Org created via github_enterprise_organization in the same module
  • as the single resource in the module and import

The PAT belongs to an Enterprise and Org owner and all permissions selected.
This is an EMU Enterprise account.

Actual Behavior

Here is the message

[ERROR] provider.terraform-provider-github_v6.2.2.exe: Response contains error diagnostic: @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_severity=ERROR diagnostic_summary="PATCH https://api.github.com/orgs/OMISSIS: 422 []" tf_proto_version=5.6 tf_provider_addr=provider tf_req_id=491343e0-ef75-6d3c-e12a-cfba58c7c4ca tf_rpc=ApplyResourceChange diagnostic_detail="" tf_resource_type=github_organization_settings timestamp="2024-07-01T15:13:06.315+0100"

Terraform Version

Terraform version: 1.8.5 on Win64 using integrations/github 6.2.2

Affected Resource(s)

github_organization_settings

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

No response

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 Jul 2, 2024
  2. moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Activeon Jul 2, 2024
  3. added
    Status: Up for grabs
    and removed
    Status: Triage
    on Jul 2, 2024
  4. giuliov-unum commented on Jul 23, 2024

    @giuliov-unum
    Author

    I tried the same code on a personal account and it works fine, so it seems related to EMU.

  5. stuartpurgavie commented on Sep 17, 2024

    @stuartpurgavie

    Had this issue as well when attempting to provide a parameter to an organization when that parameter was being enforced by the parent Enterprise. Removing the offending parameter resolved the issue.

    (I could not specify the parameter at all - aligning the parameter with the Enterprise requirement returned the same response. Had to comment out the parameter entirely. In my case, the parameter was members_can_fork_private_repositories.)

    The API response was much more enlightening:

    {
      "message": "Validation Failed",
      "errors": "Forking policy has been set by enterprise administrators.",
      "documentation_url": "https://docs.github.com/rest/orgs/orgs#update-an-organization",
      "status": "422"
    }

    It would be great if the Terraform Provider passed that error message through!

  6. giuliov-unum commented on Sep 20, 2024

    @giuliov-unum
    Author

    Had this issue as well when attempting to provide a parameter to an organization when that parameter was being enforced by the parent Enterprise. Removing the offending parameter resolved the issue.

    That's my problem: how do you find that @stuartpurgavie? The payload is not in the provider log, not even at the most detailed level.
    I considered using Fiddler or similar interceptor, but it is a practical impossibility with the our security configuration, and I cannot test EMU from a non-corporate machine.

  7. testworksau commented on Mar 28, 2025

    @testworksau

    I just wasted half a day of my life on this too; it is very frustrating that the only error I received was:

    Error: PATCH https://api.github.com/orgs/our-org: 422  []
    

    It would also be great if we could see what was being sent in the body of the request.

    It took me a long time to identify how the provider worked so that I could set up a PATCH request that matched what was being set (I checked the terraform json plan for this information), which has a clear as day error message that would have saved me a bunch of time:

    {
    	"message": "Validation Failed",
    	"errors": "Forking policy has been set by enterprise administrators.",
    	"documentation_url": "https://docs.github.com/rest/orgs/orgs#update-an-organization",
    	"status": "422"
    }
    

    It feels odd that a PATCH request contains all of the defined parameters, as an aside. The whole point of a PATCH is to provide the data that needs to change isn't it?

  8. vegardx commented on Apr 14, 2025

    @vegardx

    If you start with the Enterprise-level policy set to "No Policy" and only have a forking policy defined at the Organization level, then later setting a forking policy at the Enterprise level the resource will fail to be patched, and the provider will error out with a quite hard to understand error message.

  9. venkatesh-thatham commented on Jul 11, 2025

    @venkatesh-thatham

    Need help, I'm also facing same issue when I try to change

    members_can_create_pages = true
    members_can_create_public_pages = true

    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
      ~ update in-place
    
    Terraform will perform the following actions:
    
      # github_organization_settings.this will be updated in-place
      ~ resource "github_organization_settings" "this" {
          ~ members_can_create_pages                                     = false -> true
          ~ members_can_create_public_pages                              = false -> true
        }
    ╷
    │ Error: PATCH https://api.github.com/orgs/ors-dungeons-dragons: 422  []
    │ 
    │   with github_organization_settings.this,
    │   on main.tf line 1, in resource "github_organization_settings" "this":
    │    1: resource "github_organization_settings" "this" {
    │ 
    ╵

    According to my enterprise level for Pages creation settings, Private is disabled. This means that members will not be able to create private sites.

  10. added 4 commits that reference this issue on Oct 23, 2025
    265b859
    30bcb17
    2b1e4a3
    af0d7c8
  11. added 2 commits that reference this issue on Nov 10, 2025
    412d8ac
    ac2b4ea
  12. moved this from Backlog to In Review in Terraform Provideron Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsType: Bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions