-
Notifications
You must be signed in to change notification settings - Fork 892
Description
Expected Behavior
I am using v6.8.0 of the provider
Resource: github_repository_ruleset
Code sample:
resource "github_repository_ruleset" "example_push" {
name = "example_push"
repository = github_repository.example.name
target = "push"
enforcement = "active"
rules {
max_file_size {
max_file_size = 104857600 # 100 MB in bytes
}
}
}It is expected to work as per documentation
Actual Behavior
Encountered output:
Releasing state lock. This may take a few moments...
Stack trace from the terraform-provider-github_v6.8.0 plugin:
panic: interface conversion: interface {} is int, not float64
goroutine 125 [running]:
github.com/integrations/terraform-provider-github/v6/github.expandRules({0xc0008cb800?, 0xf30d8f?, 0x0?}, 0x0)
github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:447 +0x2825
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRulesetObject(0xc00019f600, {0x0, 0x0})
github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:33 +0x2c5
...
The error stack trace points to this line of code; https://github.com/integrations/terraform-provider-github/blame/b599ebb803f909746ec013d586ec2641e7615f98/github/respository_rules_utils.go#L447
maxFileSize := int64(maxFileSizeMap["max_file_size"].(float64))The type casting is just wrong because the provided "max_file_size" is of type int and the code is trying to coerce it into float64.
I have succesfully reproduced the issue with a Golang playground here: https://go.dev/play/p/rGdnrOe6lNt
You can also test it locally with the below code to reproduce:
package main
import "fmt"
func main() {
payload := map[string]interface{}{"max_file_size": 104857600}
fmt.Println(int64(payload["max_file_size"].(float64)))
}It will surely panic to "panic: interface conversion: interface {} is int, not float64"
Terraform Version
Terraform 1.11.4
integrations/github 6.8.0
Affected Resource(s)
- github_repository_ruleset
Terraform Configuration Files
resource "github_repository_ruleset" "example_push" {
name = "example_push"
repository = github_repository.example.name
target = "push"
enforcement = "active"
rules {
max_file_size {
max_file_size = 104857600 # 100 MB in bytes
}
}
}Steps to Reproduce
terraform apply
Debug Output
Panic Output
Releasing state lock. This may take a few moments...
Stack trace from the terraform-provider-github_v6.8.0 plugin:
panic: interface conversion: interface {} is int, not float64
goroutine 125 [running]:
github.com/integrations/terraform-provider-github/v6/github.expandRules({0xc0008cb800?, 0xf30d8f?, 0x0?}, 0x0)
github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:447 +0x2825
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRulesetObject(0xc00019f600, {0x0, 0x0})
github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:33 +0x2c5
...Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status