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

StateUpgradeFunc Can Receive nil State Map #386

Closed
bflad opened this issue Apr 13, 2020 · 2 comments · Fixed by #921
Closed

StateUpgradeFunc Can Receive nil State Map #386

bflad opened this issue Apr 13, 2020 · 2 comments · Fixed by #921
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Apr 13, 2020

SDK version

v1.9.0

Relevant provider source code

https://github.com/terraform-providers/terraform-provider-aws/blob/2cb4e3f7f017feb338e0ba2ffdf409d6b0c91793/aws/resource_aws_db_instance.go#L29-L36

https://github.com/terraform-providers/terraform-provider-aws/blob/2cb4e3f7f017feb338e0ba2ffdf409d6b0c91793/aws/resource_aws_db_instance_migrate.go#L381-L384

Terraform Configuration Files

Can try to provide if needed, but not sure how we got here either. 😄

Debug Output

https://gist.github.com/ca3825d27e669d6e42c4d3e40f9acaff

Expected Behavior

An error to be raised by the SDK about the situation, the SDK to skip the StateUpgradeFunc, or the State Migration documentation to mention the need for nil checking (and potentially why).

Actual Behavior

Provider panic due to lack of nil checking in StateUpgraderFunc.

Steps to Reproduce

  • terraform init (Terraform AWS Provider version 2.48.0 or earlier, which will have aws_db_instance resource with SchemaVersion: 0)
  • terraform apply
  • ??? (not sure how it got into empty raw state)
  • terraform init (Terraform AWS Provider version 2.49.0 or later)
  • terraform plan

References

@bflad bflad added the bug Something isn't working label Apr 13, 2020
@bflad bflad added the documentation Improvements or additions to documentation label Mar 30, 2022
@bflad bflad added this to the v2.13.0 milestone Mar 30, 2022
@bflad
Copy link
Contributor Author

bflad commented Mar 30, 2022

Easiest thing to do here will be to add a sentence to the StateUpgradeFunc documentation about nil checking.

@github-actions
Copy link

github-actions bot commented May 1, 2022

I'm going to lock this issue 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 similar to this, 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 May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant