Skip to content
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

[BUG]: Organization ruleset invalid property condition #1909

Closed
jcshadhara opened this issue Sep 20, 2023 · 5 comments
Closed

[BUG]: Organization ruleset invalid property condition #1909

jcshadhara opened this issue Sep 20, 2023 · 5 comments
Labels
Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@jcshadhara
Copy link

Expected Behavior

The organization ruleset specified in the terraform file applies without errors

Actual Behavior

The API throws an error when trying to apply an organization ruleset with a condition field:

│ Error: POST https://api.github.com/orgs/MyOrganization/rulesets: 422 Invalid request.
│ 
│ Invalid property /conditions: data matches no possible input. See `documentation_url`. []

Terraform Version

Terraform version >= 1.3.6
on linux_amd64
provider registry.terraform.io/integrations/github v5.37.0

Affected Resource(s)

github_organization_ruleset

Terraform Configuration Files

Ruleset configuration as follows:

resource "github_organization_ruleset" "master_main_branch_protection" {
  name        = "Master and main branches protection"
  target      = "branch"
  enforcement = "active"

  conditions {
    ref_name {
      include = [
        "refs/heads/master",
        "refs/heads/main"
      ]
      exclude = []
    }
  }

  rules {
    deletion         = true
    non_fast_forward = true
    pull_request {
      dismiss_stale_reviews_on_push   = true
      require_code_owner_review       = true
      required_approving_review_count = 1
      require_last_push_approval      = true
    }
  }
}


### Steps to Reproduce

_No response_

### Debug Output

_No response_

### Panic Output

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
@jcshadhara jcshadhara added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Sep 20, 2023
@nickfloyd nickfloyd moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Sep 20, 2023
@o-sama
Copy link
Contributor

o-sama commented Sep 20, 2023

Hi @jcshadhara, i think I know what's happening. Can you try setting either repository_name or repository_id and reporting back please?

The API expects one of them to be defined even if it's empty.

I'll add that to the documentation and potentially change the schema to reflect that, but it could potentially be a major version change so I'll look into that before saying anything for sure.

Hope this helps!

@jcshadhara
Copy link
Author

I confirm that adding the following code into the conditions property made it work:

repository_name {
  include = []
  exclude = []
}

Before adding the aforementioned piece of code, I tried with the property repository_id but threw the same error posted in the main post.

@o-sama
Copy link
Contributor

o-sama commented Sep 21, 2023

Interesting, let me play around with that. The API should accept the repository_id and ref_name combination as per the docs

@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Oct 20, 2023
@tj-smith47
Copy link

This still does not reflect in the documentaiton: https://registry.terraform.io/providers/integrations/github/latest/docs/resources/organization_ruleset

There is also an undocumented property under conditions.repository_name called protected that shows when running apply.

Copy link

github-actions bot commented Dec 3, 2024

👋 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!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Dec 3, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@github-project-automation github-project-automation bot moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Active Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

4 participants