The TestAccELBV2ListenerRuleDataSource_actionForwardWeightedStickiness acceptance test uses a test configuration which intermittently causes unit tests to panic.
panic: runtime error: slice bounds out of range [:30] with length 29 [recovered]
panic: runtime error: slice bounds out of range [:30] with length 29
goroutine 99 [running]:
testing.tRunner.func1.2({0x18f7af40, 0xc000da0e10})
/opt/hostedtoolcache/go/1.23.2/x64/src/testing/testing.go:1632 +0x230
testing.tRunner.func1()
/opt/hostedtoolcache/go/1.23.2/x64/src/testing/testing.go:1635 +0x35e
panic({0x18f7af40?, 0xc000da0e10?})
/opt/hostedtoolcache/go/1.23.2/x64/src/runtime/panic.go:785 +0x132
github.com/hashicorp/terraform-provider-aws/internal/service/elbv2_test.testAccListenerRuleDataSourceConfig_actionForwardWeightedStickiness({0xc000d42100, 0x1d})
/home/runner/work/terraform-provider-aws/terraform-provider-aws/internal/service/elbv2/listener_rule_data_source_test.go:1109 +0x23a
github.com/hashicorp/terraform-provider-aws/internal/service/elbv2_test.TestAccELBV2ListenerRuleDataSource_actionForwardWeightedStickiness(0xc002045d40)
/home/runner/work/terraform-provider-aws/terraform-provider-aws/internal/service/elbv2/listener_rule_data_source_test.go:445 +0x1e6
testing.tRunner(0xc002045d40, 0x19ac9410)
/opt/hostedtoolcache/go/1.23.2/x64/src/testing/testing.go:1690 +0xf4
created by testing.(*T).Run in goroutine 1
/opt/hostedtoolcache/go/1.23.2/x64/src/testing/testing.go:1743 +0x390
FAIL github.com/hashicorp/terraform-provider-aws/internal/service/elbv2 2.344s
The root of the issue is this attempt to truncate the generated resource name to 30 characters in order to meet the AWS requirement for ELB target group names to be 32 characters or less.
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Description
The
TestAccELBV2ListenerRuleDataSource_actionForwardWeightedStickiness
acceptance test uses a test configuration which intermittently causes unit tests to panic.The root of the issue is this attempt to truncate the generated resource name to 30 characters in order to meet the AWS requirement for ELB target group names to be 32 characters or less.
https://github.com/hashicorp/terraform-provider-aws/blob/a6711969ea28cfce6821a37e95699a7c892f3c14/internal/service/elbv2/listener_rule_data_source_test.go#L1108-L1110
At times the generated resource name may be less than 30 bytes in length, causing a crash.
References
https://github.com/hashicorp/terraform-provider-aws/actions/runs/11782921152/job/32819162741
Would you like to implement a fix?
None