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

Avoid panic on attribute NilType (nested attributes) #44

Merged
merged 2 commits into from
Oct 1, 2021

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Oct 1, 2021

Marshalling a schema of the recently released awscc provider causes panic due to the fact that it uses nested attributes, which in turn makes the "standard" AttributeType nil/NilType which hits this line in cty:
https://github.com/zclconf/go-cty/blob/e5d3f1507f80d88b60e58c4644f462636f400c98/cty/json.go#L85-L87

The relevant part of schema is here:
https://github.com/hashicorp/terraform-provider-awscc/blob/c4053aaf5aa3193cda725f79e20139ad6cdd73b2/internal/provider/provider.go#L118-L186

This panic was discovered in our LS CI tests:
https://github.com/hashicorp/terraform-ls/pull/659/checks#step:6:69

The solution loosely follows implementation in TF Core:
https://github.com/hashicorp/terraform/blob/0062e7112aac83304ea906f08c5aeb89b4ebfefa/internal/command/jsonprovider/attribute.go#L39-L54

@radeksimko radeksimko added the bug Something isn't working label Oct 1, 2021
@radeksimko radeksimko marked this pull request as ready for review October 1, 2021 11:14
@radeksimko radeksimko merged commit d1018bf into main Oct 1, 2021
@radeksimko radeksimko deleted the fix-nested-attr-support branch October 1, 2021 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants