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 for unchecked pointer read of resource Identifier #2027

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

thisdougb
Copy link
Contributor

@thisdougb thisdougb commented Sep 19, 2024

When reading the resource Identifier (ptr) string after requesting a resource creation, if the creation failed then the ptr may be nil. Currently we try to use the Identifier attribute without check for nil, which causes a panic.

This fix initialises the id string var, and populates it only if the Identifier is not nil.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Closes #1480
Closes #2057

@jar-b
Copy link
Member

jar-b commented Oct 9, 2024

Thanks for your contribution, @thisdougb!

Just made one minor adjustment to the conditional to ensure a nil progressEvent won't be dereferenced. A nil progressEvent.Identifer value is an acceptable input to aws.ToString, which will convert a nil value to an empty string.

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 🎉

% TF_LOG=ERROR make testacc PKG_NAME=internal/aws/logs TESTARGS='-run=TestAccAWSLogsLogGroup_\|TestAccAWSLogsLogGroupDataSource_'
TF_ACC=1 go test ./internal/aws/logs -v -count 1 -parallel 20 -run=TestAccAWSLogsLogGroup_\|TestAccAWSLogsLogGroupDataSource_ -timeout 180m

--- PASS: TestAccAWSLogsLogGroupDataSource_NonExistent (1.28s)
--- PASS: TestAccAWSLogsLogGroupDataSource_basic (25.39s)
--- PASS: TestAccAWSLogsLogGroup_basic (26.21s)
--- PASS: TestAccAWSLogsLogGroup_disappears (32.14s)
--- PASS: TestAccAWSLogsLogGroup_update (39.15s)
PASS
ok      github.com/hashicorp/terraform-provider-awscc/internal/aws/logs 39.933s

@jar-b jar-b merged commit 36fef6d into hashicorp:main Oct 9, 2024
11 checks passed
@thisdougb
Copy link
Contributor Author

Great, thanks @jar-b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants