Skip to content

github_organization_settings errors for forking policy has been set by enterprise administrators #1333

Closed

Description

@Yvonne-YAO

Hi there,

We used EMU, from enterprise level has set fork policy (false).
We want to deploy github_organization_settings to update the organization(which seems can not create but update using update rest api),
but can not work. I think your github_organization_settings api set all input values for rest api including members_can_fork_private_repositories, but when run terraform apply and come out 422 Validation Failed errors because forking policy has been set by enterprise administrators.

If there any possible not to input this members_can_fork_private_repositories in your api calling rest api if no input from users?

Thanks a lot.

Terraform Version

Terraform v1.3.2
on linux_amd64

  • provider registry.terraform.io/hashicorp/github v5.3.0
  • provider registry.terraform.io/integrations/github v5.3.0

Affected Resource(s)

  • github_organization_settings

Terraform Configuration Files

# version.tf
terraform {
  required_version = ">= 1.3.0"

  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 5.3"
    }
  }
}

# provider.tf
provider "github" {

}

#org-settings.tf
# Org settings
# Please change variables values if you test
# Even I comment fork policy line, can not work
resource "github_organization_settings" "settings" {
  billing_email = "[email protected]"
  company                                                      = "test"
  email                                    = "[email protected]"
  twitter_username                         = ""
  location                                 ="mel"
  name                                     = "fullservice-test"
  description                              = "test"
  has_organization_projects                = true
  has_repository_projects                  = true
  default_repository_permission            = "none"
  members_can_create_repositories          = true
  members_can_create_public_repositories   =  false
  members_can_create_private_repositories  = true
  members_can_create_internal_repositories = true
  members_can_create_pages                 = true
  members_can_create_public_pages          =  false
  members_can_create_private_pages         = true
  members_can_fork_private_repositories    = false
  web_commit_signoff_required              = false

  dependabot_alerts_enabled_for_new_repositories           = true
  dependabot_security_updates_enabled_for_new_repositories = true
  dependency_graph_enabled_for_new_repositories            = true
}

Debug Output

2022-10-18T18:15:10.153+1100 [DEBUG] provider.terraform-provider-github_v5.3.0: {
2022-10-18T18:15:10.153+1100 [DEBUG] provider.terraform-provider-github_v5.3.0: "message": "Validation Failed",
2022-10-18T18:15:10.153+1100 [DEBUG] provider.terraform-provider-github_v5.3.0: "errors": "Forking policy has been set by enterprise administrators.",
2022-10-18T18:15:10.153+1100 [DEBUG] provider.terraform-provider-github_v5.3.0: "documentation_url": "https://docs.github.com/rest/reference/orgs#update-an-organization"
2022-10-18T18:15:10.153+1100 [DEBUG] provider.terraform-provider-github_v5.3.0: }
2022-10-18T18:15:10.153+1100 [DEBUG] provider.terraform-provider-github_v5.3.0: -----------------------------------------------------

2022-10-18T18:15:10.169+1100 [TRACE] statemgr.Filesystem: writing snapshot at ./terraform.tfstate
Error: PATCH https://api.github.com/orgs/***-fullservice-test: 422 Validation Failed []

with module.fullservice-test.github_organization_settings.settings,
on modules/gh-org/main.tf line 13, in resource "github_organization_settings" "settings":
13: resource "github_organization_settings" "settings" {

Expected Behavior

Can update organization settings

Actual Behavior

Error: PATCH https://api.github.com/orgs/***-fullservice-test: 422 Validation Failed []
errors": "Forking policy has been set by enterprise administrators.",

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform import import existing organization manually created
  2. terraform init
  3. terraform apply

Important Factoids

My PAT token have full admin permissions, I had tried rest api to update org directly, can update the org if not input members_can_fork_private_repositories, if input it can not work cos enterprise level has controlled this.

Activity

  1. fatenhealy commented on Oct 19, 2022

    @fatenhealy

    Thanks @Yvonne-YAO for raising this issue 👍🏼
    cc @kuhlman-labs FYI Thanks in advance 🙏🏼

  2. kuhlman-labs commented on Oct 19, 2022

    @kuhlman-labs
    Contributor

    @Yvonne-YAO I will be investigating this today.

  3. kfcampbell commented on Oct 27, 2022

    @kfcampbell
    Contributor

    @kuhlman-labs any thoughts? I wouldn't mind pairing on this with you if you'd like a second pair of eyes!

  4. kuhlman-labs commented on Oct 28, 2022

    @kuhlman-labs
    Contributor

    Yes, that would be great!

  5. added
    Type: Bug
    Status: Up for grabs
    on Nov 9, 2022
  6. kuhlman-labs commented on Nov 15, 2022

    @kuhlman-labs
    Contributor

    @Yvonne-YAO @fatenhealy I have a PR submitted to fix this issue here:
    #1362

  7. Yvonne-YAO commented on Nov 18, 2022

    @Yvonne-YAO
    Author

    @Yvonne-YAO @fatenhealy I have a PR submitted to fix this issue here: #1362

    @kuhlman-labs @kfcampbell @fatenhealy Great! Thanks all :)

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions