Skip to content

[BUG]: Panic in expandConditions when conditions.ref_name is nil/empty #3299

@milagrofrost

Description

@milagrofrost

Expected Behavior

When applying a github_repository_ruleset resource with an empty array conditions.ref_name, the provider should either produce a validation error or treat it as empty (not panic).

Actual Behavior

Terraform plan/apply fails with a panic:

panic: interface conversion: interface {} is nil, not map[string]interface {}

Stack trace:
by using the github.com/integrations/terraform-provider-github/v6/github.expandConditions function (util_rules.go:194) when conditions.ref_name is empty array or contains nil, the provider panics rather than failing gracefully.

Terraform Version

Terraform v1.9.5
provider registry.terraform.io/integrations/github v6.11.1

Affected Resource(s)

  • github_repository_ruleset

Terraform Configuration Files

resource "github_repository_ruleset" "test" {
  repository = "some-repo"
  name = "test"
  target = "branch"
  enforcement = "disabled"

  conditions {
    ref_name {
      # No include/exclude specified or empty arrays
    }
  }
  rules {
    creation = true
  }
}

Steps to Reproduce

  1. Write the above github_repository_ruleset resource with an empty array conditions.ref_name block
  2. Run terraform apply

Debug Output

Panic Output

panic: interface conversion: interface {} is nil, not map[string]interface {}

github.com/integrations/terraform-provider-github/v6/github.expandConditions({0xc00067d2e0, ...}, 0x0)
	github.com/integrations/terraform-provider-github/v6/github/util_rules.go:194 +0xb6b
...
Error: The terraform-provider-github_v6.11.1 plugin crashed!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Good first issueGood for newcomersStatus: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documented

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions