-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal/flex: handle nil items in FlattenStringList #38886
Conversation
Community NoteVoting for Prioritization
For Submitters
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀.
CHANGELOG?
Prior to this change, the `FlattenStringList` function would attempt to dereference `nil` items when provided in the source slice. Now `nil` items are skipped and omitted from the resulting `[]interface{}{}` return value. Before: ```console % go test -count=1 ./internal/flex/... -run=TestFlattenStringList --- FAIL: TestFlattenStringList (0.00s) --- FAIL: TestFlattenStringList/nil_item (0.00s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10319c57c] goroutine 9 [running]: testing.tRunner.func1.2({0x10369e4c0, 0x103ab3520}) /Users/jaredbaker/sdk/go1.22.6/src/testing/testing.go:1631 +0x1c4 testing.tRunner.func1() /Users/jaredbaker/sdk/go1.22.6/src/testing/testing.go:1634 +0x33c panic({0x10369e4c0?, 0x103ab3520?}) /Users/jaredbaker/sdk/go1.22.6/src/runtime/panic.go:770 +0x124 github.com/hashicorp/terraform-provider-aws/internal/flex.FlattenStringList(...) /Users/jaredbaker/development/terraform-provider-aws/internal/flex/flex.go:107 github.com/hashicorp/terraform-provider-aws/internal/flex.TestFlattenStringList.func1(0x14000799ba0) /Users/jaredbaker/development/terraform-provider-aws/internal/flex/flex_test.go:550 +0x9c testing.tRunner(0x14000799ba0, 0x14000409ea0) /Users/jaredbaker/sdk/go1.22.6/src/testing/testing.go:1689 +0xec created by testing.(*T).Run in goroutine 6 /Users/jaredbaker/sdk/go1.22.6/src/testing/testing.go:1742 +0x318 FAIL github.com/hashicorp/terraform-provider-aws/internal/flex 0.433s ``` After: ```console % go test -count=1 ./internal/flex/... -run=TestFlattenStringList ok github.com/hashicorp/terraform-provider-aws/internal/flex 0.634s ```
This functionality has been released in v5.63.1 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Description
Prior to this change, the
FlattenStringList
function would attempt to dereferencenil
items when provided in the source slice. Nownil
items are skipped and omitted from the resulting[]interface{}{}
return value.Before:
After:
Relations
Closes #34199