Skip to content
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

Fix Value Conversion Error panics for Plugin Framework resources when null tag values are specified #34319

Merged
merged 8 commits into from
Nov 9, 2023

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Nov 8, 2023

Description

Handle null tag values for resources using Terraform Plugin Framework.

Relations

Closes #34294.

References

Output from Acceptance Testing

Before

% make testacc TESTARGS='-run=TestAccAppConfigEnvironment_tagsWithNullValue' PKG=appconfig
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/appconfig/... -v -count 1 -parallel 20  -run=TestAccAppConfigEnvironment_tagsWithNullValue -timeout 360m
=== RUN   TestAccAppConfigEnvironment_tagsWithNullValue
=== PAUSE TestAccAppConfigEnvironment_tagsWithNullValue
=== CONT  TestAccAppConfigEnvironment_tagsWithNullValue
panic: Value Conversion Error

An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider developer:

Received null value, however the target type cannot handle null values. Use the corresponding `types` package type, a pointer type or a custom type that handles null values.

Path: ["key2"]
Target Type: string
Suggested `types` Type: basetypes.StringValue
Suggested Pointer Type: *string
AutoFlEx

Expand[basetypes.MapValue, *map[string]string]

goroutine 889 [running]:
github.com/hashicorp/terraform-provider-aws/internal/framework/flex.panicOnError(...)
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/framework/flex/bool.go:44
github.com/hashicorp/terraform-provider-aws/internal/framework/flex.ExpandFrameworkStringValueMap({0x102fd820?, 0xc0043c1170?}, {0x103095e0?, 0xc0043b4820?})
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/framework/flex/map.go:25 +0xac
github.com/hashicorp/terraform-provider-aws/internal/tags.New({0x102fd820, 0xc0043c1170}, {0xebf00e0?, 0xc0043ac398?})
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/tags/key_value_tags.go:647 +0x50b
github.com/hashicorp/terraform-provider-aws/internal/framework.(*ResourceWithConfigure).SetTagsAll(0xc005fb3ad0, {0x102fd820, 0xc0043c1170}, {{{{0x1030b1e8, 0xc00438d2c0}, {0xd46b060, 0xc00438cea0}}, {0x103149d8, 0xc000797450}}, {{{0x1030b1e8, ...}, ...}, ...}, ...}, ...)
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/framework/base.go:90 +0x3b5
github.com/hashicorp/terraform-provider-aws/internal/service/appconfig.(*resourceEnvironment).ModifyPlan(0x0?, {0x102fd820?, 0xc0043c1170?}, {{{{0x1030b1e8, 0xc00438d2c0}, {0xd46b060, 0xc00438cea0}}, {0x103149d8, 0xc000797450}}, {{{0x1030b1e8, ...}, ...}, ...}, ...}, ...)
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/service/appconfig/environment.go:314 +0x7b
github.com/hashicorp/terraform-provider-aws/internal/provider/fwprovider.(*wrappedResource).ModifyPlan(0xc004a2d640, {0x102fd820, 0xc004383fb0}, {{{{0x1030b1e8, 0xc00438d2c0}, {0xd46b060, 0xc00438cea0}}, {0x103149d8, 0xc000797450}}, {{{0x1030b1e8, ...}, ...}, ...}, ...}, ...)
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/provider/fwprovider/intercept.go:285 +0xff
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).PlanResourceChange(0xc002509080, {0x102fd820, 0xc004383fb0}, 0xc005ebf540, 0xc0043ad418)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/internal/fwserver/server_planresourcechange.go:280 +0x1403
github.com/hashicorp/terraform-plugin-framework/internal/proto5server.(*Server).PlanResourceChange(0xc002509080, {0x102fd820?, 0xc004383ec0?}, 0xc005ebf4a0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/internal/proto5server/server_planresourcechange.go:55 +0x41a
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).PlanResourceChange(0xc000969f80, {0x102fd820?, 0xc004383bf0?}, 0xc005ebf4a0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tf5muxserver/mux_server_PlanResourceChange.go:73 +0x2d4
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).PlanResourceChange(0xc00234cfa0, {0x102fd820?, 0xc0043833e0?}, 0xc0024e43f0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:824 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler({0xebfc820?, 0xc00234cfa0}, {0x102fd820, 0xc0043833e0}, 0xc0024e4380, 0x0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:449 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000786780, {0x1030c240, 0xc005f18680}, 0xc004385680, 0xc00255a8a0, 0x16a075c0, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:1376 +0xdd2
google.golang.org/grpc.(*Server).handleStream(0xc000786780, {0x1030c240, 0xc005f18680}, 0xc004385680, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:1753 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:998 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:996 +0x18c
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/appconfig	8.422s
FAIL
make: *** [testacc] Error 1

After

% make testacc TESTARGS='-run=TestAccAppConfigEnvironment_' PKG=appconfig ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/appconfig/... -v -count 1 -parallel 2  -run=TestAccAppConfigEnvironment_ -timeout 360m
=== RUN   TestAccAppConfigEnvironment_basic
=== PAUSE TestAccAppConfigEnvironment_basic
=== RUN   TestAccAppConfigEnvironment_disappears
=== PAUSE TestAccAppConfigEnvironment_disappears
=== RUN   TestAccAppConfigEnvironment_updateName
=== PAUSE TestAccAppConfigEnvironment_updateName
=== RUN   TestAccAppConfigEnvironment_updateDescription
=== PAUSE TestAccAppConfigEnvironment_updateDescription
=== RUN   TestAccAppConfigEnvironment_monitors
=== PAUSE TestAccAppConfigEnvironment_monitors
=== RUN   TestAccAppConfigEnvironment_multipleEnvironments
=== PAUSE TestAccAppConfigEnvironment_multipleEnvironments
=== RUN   TestAccAppConfigEnvironment_tags
=== PAUSE TestAccAppConfigEnvironment_tags
=== RUN   TestAccAppConfigEnvironment_tagsWithNullValue
=== PAUSE TestAccAppConfigEnvironment_tagsWithNullValue
=== RUN   TestAccAppConfigEnvironment_frameworkMigration_basic
=== PAUSE TestAccAppConfigEnvironment_frameworkMigration_basic
=== RUN   TestAccAppConfigEnvironment_frameworkMigration_monitors
=== PAUSE TestAccAppConfigEnvironment_frameworkMigration_monitors
=== CONT  TestAccAppConfigEnvironment_basic
=== CONT  TestAccAppConfigEnvironment_multipleEnvironments
--- PASS: TestAccAppConfigEnvironment_basic (25.73s)
=== CONT  TestAccAppConfigEnvironment_updateDescription
--- PASS: TestAccAppConfigEnvironment_multipleEnvironments (50.61s)
=== CONT  TestAccAppConfigEnvironment_monitors
--- PASS: TestAccAppConfigEnvironment_updateDescription (65.22s)
=== CONT  TestAccAppConfigEnvironment_frameworkMigration_basic
--- PASS: TestAccAppConfigEnvironment_monitors (66.32s)
=== CONT  TestAccAppConfigEnvironment_frameworkMigration_monitors
--- PASS: TestAccAppConfigEnvironment_frameworkMigration_basic (80.31s)
=== CONT  TestAccAppConfigEnvironment_updateName
--- PASS: TestAccAppConfigEnvironment_frameworkMigration_monitors (78.93s)
=== CONT  TestAccAppConfigEnvironment_tagsWithNullValue
--- PASS: TestAccAppConfigEnvironment_updateName (41.51s)
=== CONT  TestAccAppConfigEnvironment_disappears
--- PASS: TestAccAppConfigEnvironment_tagsWithNullValue (29.66s)
=== CONT  TestAccAppConfigEnvironment_tags
--- PASS: TestAccAppConfigEnvironment_disappears (21.29s)
--- PASS: TestAccAppConfigEnvironment_tags (55.07s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/appconfig	286.101s

@ewbankkit ewbankkit changed the title Fix Value Conversion Error panics for Framework when null tag values are specified Fix Value Conversion Error panics for Framework resources when null tag values are specified Nov 8, 2023
Copy link

github-actions bot commented Nov 8, 2023

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/appconfig Issues and PRs that pertain to the appconfig service. sweeper Pertains to changes to or issues with the sweeper. size/XL Managed by automation to categorize the size of a PR. tags Pertains to resource tagging. labels Nov 8, 2023
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 8, 2023
Copy link

github-actions bot commented Nov 8, 2023

Thank you for your contribution! 🚀

A new usage of AWS SDK for Go V1 was detected. Please prefer AWS SDK for Go V2 for all net-new services. If this is an enhancement or bug fix to an existing AWS SDK Go V1 based resource, this comment can be safely ignored.

For additional information refer to the AWS SDK for Go Versions page in the contributor guide.

@ewbankkit ewbankkit changed the title Fix Value Conversion Error panics for Framework resources when null tag values are specified Fix Value Conversion Error panics for Plugin Framework resources when null tag values are specified Nov 8, 2023
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

% make testacc TESTARGS='-run=TestAccAppConfigEnvironment_' PKG=appconfig
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/appconfig/... -v -count 1 -parallel 20  -run=TestAccAppConfigEnvironment_ -timeout 360m
=== RUN   TestAccAppConfigEnvironment_basic
=== PAUSE TestAccAppConfigEnvironment_basic
=== RUN   TestAccAppConfigEnvironment_disappears
=== PAUSE TestAccAppConfigEnvironment_disappears
=== RUN   TestAccAppConfigEnvironment_updateName
=== PAUSE TestAccAppConfigEnvironment_updateName
=== RUN   TestAccAppConfigEnvironment_updateDescription
=== PAUSE TestAccAppConfigEnvironment_updateDescription
=== RUN   TestAccAppConfigEnvironment_monitors
=== PAUSE TestAccAppConfigEnvironment_monitors
=== RUN   TestAccAppConfigEnvironment_multipleEnvironments
=== PAUSE TestAccAppConfigEnvironment_multipleEnvironments
=== RUN   TestAccAppConfigEnvironment_tags
=== PAUSE TestAccAppConfigEnvironment_tags
=== RUN   TestAccAppConfigEnvironment_tagsWithNullValue
=== PAUSE TestAccAppConfigEnvironment_tagsWithNullValue
=== RUN   TestAccAppConfigEnvironment_frameworkMigration_basic
=== PAUSE TestAccAppConfigEnvironment_frameworkMigration_basic
=== RUN   TestAccAppConfigEnvironment_frameworkMigration_monitors
=== PAUSE TestAccAppConfigEnvironment_frameworkMigration_monitors
=== CONT  TestAccAppConfigEnvironment_basic
=== CONT  TestAccAppConfigEnvironment_multipleEnvironments
=== CONT  TestAccAppConfigEnvironment_frameworkMigration_basic
=== CONT  TestAccAppConfigEnvironment_frameworkMigration_monitors
=== CONT  TestAccAppConfigEnvironment_tagsWithNullValue
=== CONT  TestAccAppConfigEnvironment_updateDescription
=== CONT  TestAccAppConfigEnvironment_monitors
=== CONT  TestAccAppConfigEnvironment_updateName
=== CONT  TestAccAppConfigEnvironment_tags
=== CONT  TestAccAppConfigEnvironment_disappears
--- PASS: TestAccAppConfigEnvironment_basic (120.19s)
--- PASS: TestAccAppConfigEnvironment_frameworkMigration_basic (120.32s)
--- PASS: TestAccAppConfigEnvironment_disappears (121.78s)
--- PASS: TestAccAppConfigEnvironment_tagsWithNullValue (123.16s)
--- PASS: TestAccAppConfigEnvironment_updateName (182.06s)
--- PASS: TestAccAppConfigEnvironment_frameworkMigration_monitors (182.59s)
--- PASS: TestAccAppConfigEnvironment_multipleEnvironments (197.87s)
--- PASS: TestAccAppConfigEnvironment_tags (223.83s)
--- PASS: TestAccAppConfigEnvironment_updateDescription (226.76s)
--- PASS: TestAccAppConfigEnvironment_monitors (331.29s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/appconfig  334.582s

@ewbankkit ewbankkit merged commit 6ef42d2 into main Nov 9, 2023
46 checks passed
@ewbankkit ewbankkit deleted the b-ExpandFrameworkStringValueMap-crash branch November 9, 2023 18:27
@github-actions github-actions bot added this to the v5.25.0 milestone Nov 9, 2023
github-actions bot pushed a commit that referenced this pull request Nov 9, 2023
Copy link

This functionality has been released in v5.25.0 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!

Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2023
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/appconfig Issues and PRs that pertain to the appconfig service. size/XL Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. tags Pertains to resource tagging. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: aws_opensearchserverless_collection.collection tagging failed to handle Value Conversion Error
3 participants