integrations / integrations/terraform-provider-github
[BUG]: Panic in expandConditions when conditions.ref_name is nil/empty
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 8
Description
### 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
```hcl
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
```shell
```
### Panic Output
```shell
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
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Assessment
This issue has not been assessed yet.