fix: allow empty required_workflow blocks in required_workflows rule#3301
fix: allow empty required_workflow blocks in required_workflows rule#3301sc0rp10 wants to merge 2 commits intointegrations:mainfrom
Conversation
The GitHub UI and API allow creating a required_workflows rule without specifying any workflows. However, the Terraform schema enforced MinItems: 1 and Required: true on the required_workflow sub-block, making it impossible to represent or import such rulesets. Change required_workflow from Required to Optional and remove the MinItems constraint so that an empty workflow list is accepted. Fixes integrations#3217
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
Validates that a required_workflows rule with no required_workflow sub-blocks is accepted, matching GitHub UI/API behavior.
|
@sc0rp10 Thanks for the PR! Question: Does the "Require workflows to pass" toggle without specified workflows do anything? AFAIK it only affects specified workflows |
|
@deiga Thanks for the review! You're right that an empty
The provider should faithfully represent any state the API can return. Since the API accepts and returns |
|
To add more context: the primary use case here is enforcing that PRs have successful checks before merge. The "Require workflows to pass" toggle in rulesets serves as a gate — even without specifying particular workflows, it enforces that PR checks must succeed. Without being able to represent this state in Terraform, users are forced to disable the rule entirely, losing that enforcement. |
|
Even if the UI allows you to specify an empty list of required workflows, it doesn't do anything. The UI states "Require all changes made to a targeted branch to pass the specified workflows before they can be merged." and the API has similar wording https://docs.github.com/en/rest/orgs/rules?apiVersion=2026-03-10#create-an-organization-repository-ruleset There is no use-case for the provider to allow this.
This is not true, the provider should be an abstraction layer on top of the API
I think you're mixing something up. AFAIK Import doesn't fail if only the boolean has been set, it would just cause drift. Can you show me output of a failing import? |
Resolves #3217
Before the change?
required_workflowsub-block insiderequired_workflowswas defined withRequired: trueandMinItems: 1, forcing users to specify at least one workflow.After the change?
required_workflowfromRequired: truetoOptional: trueand removed theMinItems: 1constraint.required_workflows {}block (with norequired_workflowsub-blocks) is now valid, matching the behavior of the GitHub UI and API.Pull request checklist
Does this introduce a breaking change?