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

aws_codebuild_project: plan crashes with "interface {} is nil, not string", "unexpected EOF", and "connection is shut down" #2673

Closed
davido-bs opened this issue Dec 15, 2017 · 5 comments · Fixed by #3011
Assignees
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/codebuild Issues and PRs that pertain to the codebuild service.
Milestone

Comments

@davido-bs
Copy link

Terraform Version

0.10.8, AWS provider 1.5.0

Debug/Panic Output

https://gist.github.com/davido-bs/52edbd47426b69e5efd10e957ed1c417

Expected Behavior

Plan should have been created.

Actual Behavior

Error in the logs: interface {} is nil, not string. In the gist provided, it manifests itself as an "unexpected EOF" error.

Steps to Reproduce

  1. terraform plan

Important Factoids

The reproducability of this may be due to handling erroneous "stray" values in the state, as we have been doing a fairly large refactor. This is not the first time we've encountered this message though, so I'm putting it out there "for the record".

@davido-bs
Copy link
Author

davido-bs commented Dec 19, 2017

Only real "workaround" at the moment seems to be to manually remove all aws_codebuild_project resources, then remove the actual projects themselves, then run a plan again to have it create the projects again. Obviously not ideal.

@apparentlymart apparentlymart added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Dec 20, 2017
@apparentlymart
Copy link
Contributor

Hi @davido-bs! Thanks for reporting this.

What follows are some notes from my initial investigation that may be useful to someone working on a fix for this in future:

Normally the provider framework guarantees that a set hash function will see only values of the expected type for a given attribute due to the schema, but it looks like this particular resource is doing some custom work directly with the Set type, rather than working directly with the sets provided by the framework:

https://github.com/terraform-providers/terraform-provider-aws/blob/cba83a50b79c55183b918152cd94aed1eaac8c98/aws/resource_aws_codebuild_project.go#L526-L557

The problem here seems to be on line 545, where it conditionally populates the relevant attribute, creating a situation where this might be nil. It should instead be writing a valid empty value (in this case, an empty string) to preserve the invariant that the hash function is expecting.

With that said, normally we avoid this sort of complexity by assigning to set attributes using a Go slice rather than a schema.Set, so probably an easier path here would be to change this flattenAwsCodebuildProjectSource function to return []interface{} and let that be assigned to the attribute in the schema. ResourceData.Set accepts a Go slice when assigning to a set, and handles the conversion to the appropriate set type automatically.

@radeksimko radeksimko added the service/codebuild Issues and PRs that pertain to the codebuild service. label Jan 12, 2018
@bflad bflad added this to the v1.7.1 milestone Jan 12, 2018
@bflad bflad self-assigned this Jan 12, 2018
@bflad
Copy link
Contributor

bflad commented Jan 17, 2018

This has landed in master and will ship with v1.7.1 set to release later this week. Happy Terraform'ing! 🎉

@bflad
Copy link
Contributor

bflad commented Jan 22, 2018

This has been released in terraform-provider-aws version 1.7.1. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 8, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
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. service/codebuild Issues and PRs that pertain to the codebuild service.
Projects
None yet
4 participants