Skip to content

[BUG] fix rulesets update_allows_fetch_and_merge validation - #3547

Open
deiga wants to merge 10 commits into
integrations:mainfrom
F-Secure-web:fix-update_allows_fetch_and_merge-validation
Open

[BUG] fix rulesets update_allows_fetch_and_merge validation#3547
deiga wants to merge 10 commits into
integrations:mainfrom
F-Secure-web:fix-update_allows_fetch_and_merge-validation

Conversation

@deiga

@deiga deiga commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Resolves #3543


Before the change?

  • rules.0.update_allows_fetch_and_merge is being marked as invalid config for repository ruleset

After the change?

  • rules.0.update_allows_fetch_and_merge will be allowed as config for repository rulesets
  • Adds Create and Update validation to ensure only Forked repos can set rules.0.update_allows_fetch_and_merge
  • Adds test helper for archiving a repository and for configuring repository visibility
  • Refactors github_repository_ruleset tests to follow modern practices

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Jul 16, 2026
@deiga
deiga force-pushed the fix-update_allows_fetch_and_merge-validation branch from e68c40e to ce2ffca Compare July 19, 2026 06:20
@deiga
deiga requested a review from Copilot July 19, 2026 06:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@deiga
deiga marked this pull request as ready for review July 19, 2026 06:49
@deiga
deiga requested review from Copilot and stevehipwell July 19, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread github/resource_github_repository_ruleset_test.go
Comment thread github/acc_helpers_test.go Outdated
Comment thread github/acc_helpers_test.go Outdated
Comment thread github/resource_github_repository_ruleset_test.go Outdated
Comment thread github/resource_github_repository_ruleset_test.go Outdated
@deiga deiga added r/repository_ruleset vNextPatch These issues and PRs should be included in the next patch release labels Jul 28, 2026
@deiga deiga added this to the v6.13.1 milestone Jul 28, 2026
@deiga
deiga force-pushed the fix-update_allows_fetch_and_merge-validation branch from 2c4dedb to 5bdcf8c Compare July 28, 2026 19:08
@deiga
deiga requested a review from stevehipwell July 28, 2026 19:08
@deiga
deiga force-pushed the fix-update_allows_fetch_and_merge-validation branch from 5bdcf8c to 2a5953e Compare August 10, 2026 16:46
dev-milos added a commit to dev-milos/terraform-provider-github that referenced this pull request Aug 17, 2026
…t validation

The validation added in 6.11.0 walks the keys of the rules block and rejects any
name absent from the allow-list of rule types. update_allows_fetch_and_merge is a
parameter of the update rule rather than a rule of its own, so it is rejected before
the expansion that folds it into UpdateRuleParameters ever runs.

Any ruleset setting it therefore fails to plan, on both branch and tag targets. The
provider contradicts itself within one version, since util_rules.go sends the value
as a parameter and never as a rule.

Cherry-picked from integrations#3547, which fixes this
upstream but is still awaiting review. Only the two lines that matter are taken; the
rest of that pull request is regenerated documentation and rewritten tests. A later
sync of this fork absorbs the change and this patch disappears with it.
mladjan-gadzic pushed a commit to G-Research-Forks/terraform-provider-github that referenced this pull request Aug 17, 2026
…t validation (#19)

The validation added in 6.11.0 walks the keys of the rules block and rejects any
name absent from the allow-list of rule types. update_allows_fetch_and_merge is a
parameter of the update rule rather than a rule of its own, so it is rejected before
the expansion that folds it into UpdateRuleParameters ever runs.

Any ruleset setting it therefore fails to plan, on both branch and tag targets. The
provider contradicts itself within one version, since util_rules.go sends the value
as a parameter and never as a rule.

Cherry-picked from integrations#3547, which fixes this
upstream but is still awaiting review. Only the two lines that matter are taken; the
rest of that pull request is regenerated documentation and rewritten tests. A later
sync of this fork absorbs the change and this patch disappears with it.

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a import-by-string-id.tf file to the examples.

Comment thread github/resource_github_repository_ruleset.go Outdated
Comment thread github/resource_github_repository_ruleset.go Outdated
Comment thread github/resource_github_repository_ruleset.go Outdated
deiga added 7 commits August 22, 2026 13:54
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…n non-forked repos

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
deiga and others added 3 commits August 22, 2026 13:54
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Co-authored-by: Steve Hipwell <steve.hipwell@gmail.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga
deiga force-pushed the fix-update_allows_fetch_and_merge-validation branch from e5bf717 to afef5c0 Compare August 22, 2026 10:56
@deiga
deiga requested a review from stevehipwell August 22, 2026 10:56

@rilical rilical left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation fix itself looks focused, but the surrounding cleanup dropped two useful pieces. create_branch_ruleset used to verify the resulting bypass actors and nested rules; it now only checks that Terraform plans a Create. The generated docs also lost the note explaining which rules apply to branch and tag targets versus push targets when the custom template was removed. Could we restore the state assertions alongside the new plan check and move that guidance into a schema description or small template section so it survives regeneration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

r/repository_ruleset Type: Bug Something isn't working as documented vNextPatch These issues and PRs should be included in the next patch release

Projects

None yet

4 participants