Skip to content

[BUG]: Ruleset, required_check should be optional #2467

Closed

Description

@marcomansi-ahold

Expected Behavior

I want to create a ruleset with a required status check with only "Require branches to be up to date before merging" enabled, like this (created through the UI):

image

Actual Behavior

Error:

│ Error: PUT https://api.github.com/repos/RoyalAholdDelhaize/gso-tech-test-marco_mansi-1/rulesets/2669259: 422 Validation Failed [{Resource: Field: Code: Message:Invalid rule 'required_status_checks': Invalid parameter required_status_checks: Invalid array contents. Errors at index 0: Expected context to be present}]
│
│ with module.gso_github_repo["gso-tech-test-marco_mansi-1"].github_repository_ruleset.ruleset,
│ on gso_github_repo/main.tf line 84, in resource "github_repository_ruleset" "ruleset":
│ 84: resource "github_repository_ruleset" "ruleset" {

Terraform Version

Terraform 1.9.8
integrations/github 6.3.1

Affected Resource(s)

  • github_repository_ruleset

Terraform Configuration Files

No response

Steps to Reproduce

I am using this code:

resource "github_repository_ruleset" "ruleset" {
  name        = "PRs & conventional commits"
  repository  = github_repository.repo.name
  target      = "branch"
  enforcement = "active"

  conditions {
    ref_name {
      include = ["~DEFAULT_BRANCH"]
      exclude = []
    }
  }

  rules {
    creation                = true
    update                  = true
    deletion                = true
    required_linear_history = true
    non_fast_forward        = true

    pull_request {
      require_last_push_approval        = true
      dismiss_stale_reviews_on_push     = true
      required_review_thread_resolution = true
      required_approving_review_count   = 1
    }

    required_status_checks {
      required_check {
        context = ""
      }
      strict_required_status_checks_policy = true
    }
  }
}

The required_check block is required and context too. But it cannot be empty

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 Nov 19, 2024
  2. kris-evans commented on Nov 20, 2024

    @kris-evans

    I'm currently experience this as well. This is actually blocking our ability to configure repositories with the Terraform provider as it overwrites the rules on deploy.

  3. moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Activeon Dec 23, 2024
  4. cam-bond commented on Apr 17, 2025

    @cam-bond

    Same here kris-evans. We want to block PR merges on any failing status checks, but we don't care what those status checks actually are, as they are so repo-specific across our org.

  5. stevehipwell commented on Apr 22, 2025

    @stevehipwell
    Collaborator

    I don't think that this is possible, if you attempt to do this in the UI you now get the following error (I think the fact that the UI used to not error was confusing and a defect).

    Image

  6. stevehipwell commented on Apr 22, 2025

    @stevehipwell
    Collaborator

    We want to block PR merges on any failing status checks, but we don't care what those status checks actually are, as they are so repo-specific across our org.

    @cam-bond you would need use an app or workflow to be registered as the required check which could then handle checking the dynamic workflows.

  7. cam-bond commented on Apr 22, 2025

    @cam-bond

    That is a very recent change on githubs side because I was able to create rulesets without any required checks last week. Bummer. It shouldn't be this hard to specify 'don't allow merges on red'.

  8. cam-bond commented on Apr 22, 2025

    @cam-bond

    And I did verify last week that the behavior with this box checked without any required status checks was different than not having that box checked at all, and was the desired behavior (we dont care what checks run just dont allow merges on red).

  9. stevehipwell commented on Apr 22, 2025

    @stevehipwell
    Collaborator

    @cam-bond I've never had it work in the way the UI used to let you configure it.

  10. stevehipwell commented on Dec 8, 2025

    @stevehipwell
    Collaborator

    @deiga I know you've got PRs open for the rulesets, do you think we could tighten up the validation to require checks to have been defined if the other options are being set?

  11. deiga commented on Dec 8, 2025

    @deiga
    Collaborator

    @deiga I know you've got PRs open for the rulesets, do you think we could tighten up the validation to require checks to have been defined if the other options are being set?

    @stevehipwell Sure thing!

  12. deiga commented on Dec 8, 2025

    @deiga
    Collaborator

    Based on manual tests on the API, it should be sufficient to ensure that context is not empty: Here's the addition: 77e8cfe

    Let me know if there are other dimensions that should be validated as well!

  13. moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Activeon Mar 22, 2026
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: TriageType: Bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions