Repository navigation
Labels
Status: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedhacktoberfestIssues for participation in Hacktoberfest
Description
Expected Behavior
Should define an empty list of required deployments.
Equivalent of ticking the box in the UI but not specifying anything. See screenshot

Actual Behavior
Throws error
The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
Seems like there was an error in repository_rules_utils.go. It fails to cast the required_deployments block to a map of strings because v[0] == nil.
Terraform Version
Terraform v1.5.7
Affected Resource(s)
- github_repository_ruleset
Terraform Configuration Files
resource "github_repository_ruleset" "failure" {
repository = <insert repo here>
name = "failure"
enforcement = "evaluate"
target = "branch"
rules {
# just here to so that removing the required_deployments block is still valid
update = true
required_deployments {
required_deployment_environments = []
}
}
}Steps to Reproduce
No response
Debug Output
No response
Panic Output
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
+ create
Terraform will perform the following actions:
# github_repository_ruleset.failure will be created
+ resource "github_repository_ruleset" "failure" {
+ enforcement = "evaluate"
+ etag = (known after apply)
+ id = (known after apply)
+ name = "failure"
+ node_id = (known after apply)
+ repository = <censored>
+ ruleset_id = (known after apply)
+ target = "branch"
+ rules {
+ update = true
+ update_allows_fetch_and_merge = false
+ required_deployments {
+ required_deployment_environments = []
}
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
github_repository_ruleset.failure: Creating...
╷
│ Error: Request cancelled
│
│ with github_repository_ruleset.failure,
│ on main.tf line 26, in resource "github_repository_ruleset" "failure":
│ 26: resource "github_repository_ruleset" "failure" {
│
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵
Stack trace from the terraform-provider-github_v5.37.0 plugin:
panic: interface conversion: interface {} is nil, not map[string]interface {}
goroutine 68 [running]:
github.com/integrations/terraform-provider-github/v5/github.expandRules({0xc0006196a0?, 0x1f5d882?, 0x1d69ac0?}, 0x0)
github.com/integrations/terraform-provider-github/v5/github/respository_rules_utils.go:242 +0x2105
github.com/integrations/terraform-provider-github/v5/github.resourceGithubRulesetObject(0xc000c22960?, {0x0, 0x0})
github.com/integrations/terraform-provider-github/v5/github/respository_rules_utils.go:32 +0x2c5
github.com/integrations/terraform-provider-github/v5/github.resourceGithubRepositoryRulesetCreate(0x1d69ac0?, {0x1cc4160?, 0xc000350400})
github.com/integrations/terraform-provider-github/v5/github/resource_github_repository_ruleset.go:425 +0x56
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00016ab40, 0xc000c41950, 0xc000c22960, {0x1cc4160, 0xc000350400})
github.com/hashicorp/[email protected]/helper/schema/resource.go:320 +0x637
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc00006ae00, 0xc0007eb900, 0x1f6909a?, 0xf?)
github.com/hashicorp/[email protected]/helper/schema/provider.go:294 +0x6a
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000802918, {0xc00096ee70?, 0x10bf886?}, 0xc00096ee70)
github.com/hashicorp/[email protected]/internal/helper/plugin/grpc_provider.go:895 +0x7c5
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1f0c0a0?, 0xc000802918}, {0x2325c10, 0xc00064e330}, 0xc00096ee00, 0x0)
github.com/hashicorp/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3305 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00067a000, {0x232b3b0, 0xc000602680}, 0xc00064aea0, 0xc000573b90, 0x2c46ee0, 0x0)
google.golang.org/[email protected]/server.go:1337 +0xde7
google.golang.org/grpc.(*Server).handleStream(0xc00067a000, {0x232b3b0, 0xc000602680}, 0xc00064aea0, 0x0)
google.golang.org/[email protected]/server.go:1714 +0x9e7
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:959 +0x8d
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 31
google.golang.org/[email protected]/server.go:957 +0x165
Error: The terraform-provider-github_v5.37.0 plugin crashed!
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Status: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedhacktoberfestIssues for participation in Hacktoberfest
Type
Projects
- StatusShow more project fields✅ Done
Activity
lewismiddleton commentedon Sep 25, 2023
Still getting the same error.
o-sama commentedon Sep 25, 2023
That's interesting. I've done the following just now:
- Installed integrations/github v5.38.0Is there anything else you can share that might help in figuring this out? Did the configuration you're trying to apply change since you initially posted the issue?
Update: @lewismiddleton Looks like using
DefaultFuncworked in solving this issue with an existing rule, but when creating a new one it still defaults to nil because of the schema for the block being a pointer. I'll create a PR for this tonight. @nickfloyd Sorry about this, do you mind reopening the issue?nickfloyd commentedon Sep 25, 2023
@o-sama and @lewismiddleton thank you for the sleuthing here. @o-sama no worries, I missed it too; thank you for the followup! ❤️
lewismiddleton commentedon Sep 26, 2023
Thanks for figuring this out. You're right I was getting this failure in the context of creating a new repository rule.
o-sama commentedon Oct 5, 2023
I had to step away for a bit due to some health issues, apologies for the delay with this. I'll try to get it out in the next day or two 🙂
kfcampbell commentedon Oct 20, 2023
@o-sama I hope you're feeling better! Thank you for all your hard work on our provider.