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/resource_aws_lambda_function: imageConfig can be null #17359

Closed
wants to merge 1 commit into from

Conversation

wuurrd
Copy link

@wuurrd wuurrd commented Jan 29, 2021

Allow flattenLambdaImageConfig to not fail if ImageConfig == null

Reproducible by importing a lambda function where the image config has not been set to anything:

 runtime error: invalid memory address or nil pointer dereference
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x484cae2]
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: goroutine 26 [running]:
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.flattenLambdaImageConfig(...)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_lambda_function.go:1322
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLambdaFunctionRead(0xc001deee00, 0x5aee120, 0xc001162000, 0xa68abe0, 0x69151d0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_lambda_function.go:724 +0x2f62
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000a460c0, 0x7235c00, 0xc0017670c0, 0xc001deee00, 0x5aee120, 0xc001162000, 0x0, 0x0, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.1/helper/schema/resource.go:290 +0x88
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000a460c0, 0x7235c00, 0xc0017670c0, 0xc000a307e0, 0x5aee120, 0xc001162000, 0xc00011ea58, 0x0, 0x0, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.1/helper/schema/resource.go:564 +0x1cb
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000cf0300, 0x7235c00, 0xc0017670c0, 0xc001767100, 0xc0017670c0, 0x6340b20, 0x65debe0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.1/helper/schema/grpc_provider.go:575 +0x43b
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ReadResource(0xc0018c8840, 0x7235c00, 0xc0017670c0, 0xc00063f9e0, 0xc0018c8840, 0xc0011c34a0, 0xc001d5eba0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/server/server.go:298 +0x105
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0x65debe0, 0xc0018c8840, 0x7235cc0, 0xc0011c34a0, 0xc00063f920, 0x0, 0x7235cc0, 0xc0011c34a0, 0xc0011d4580, 0x285)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000566fc0, 0x7258ba0, 0xc000130600, 0xc001dfe200, 0xc0015f2b70, 0xa649490, 0x0, 0x0, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0x522
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).handleStream(0xc000566fc0, 0x7258ba0, 0xc000130600, 0xc001dfe200, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xd05
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000bdedb0, 0xc000566fc0, 0x7258ba0, 0xc000130600, 0xc001dfe200)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0xa5
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: created by google.golang.org/grpc.(*Server).serveStreams.func1
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd
2021-01-29T16:58:16.675+0100 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/3.26.0/linux_amd64/terraform-provider-aws_v3.26.0_x5 pid=163969 error="exit status 2"
2021-01-29T16:58:16.675+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"

The ImageConfig can be null.

{
    ...
    "Configuration": {
        ...
        "ImageConfigResponse": {
            "Error": null,
            "ImageConfig": null
        },
    },
}

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

Relates OR Closes #0000

Output from acceptance testing:

$ go test -run TestFlattenLambdaImageConfigShouldNotFailWithEmptyImageConfig\$ . 
ok  	github.com/terraform-providers/terraform-provider-aws/aws	0.041s

...

not fail if ImageConfig == null

Reproducible by:

 runtime error: invalid memory address or nil pointer dereference
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x484cae2]
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: goroutine 26 [running]:
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.flattenLambdaImageConfig(...)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_lambda_function.go:1322
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLambdaFunctionRead(0xc001deee00, 0x5aee120, 0xc001162000, 0xa68abe0, 0x69151d0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_lambda_function.go:724 +0x2f62
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000a460c0, 0x7235c00, 0xc0017670c0, 0xc001deee00, 0x5aee120, 0xc001162000, 0x0, 0x0, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.1/helper/schema/resource.go:290 +0x88
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000a460c0, 0x7235c00, 0xc0017670c0, 0xc000a307e0, 0x5aee120, 0xc001162000, 0xc00011ea58, 0x0, 0x0, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.1/helper/schema/resource.go:564 +0x1cb
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000cf0300, 0x7235c00, 0xc0017670c0, 0xc001767100, 0xc0017670c0, 0x6340b20, 0x65debe0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.1/helper/schema/grpc_provider.go:575 +0x43b
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ReadResource(0xc0018c8840, 0x7235c00, 0xc0017670c0, 0xc00063f9e0, 0xc0018c8840, 0xc0011c34a0, 0xc001d5eba0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/server/server.go:298 +0x105
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0x65debe0, 0xc0018c8840, 0x7235cc0, 0xc0011c34a0, 0xc00063f920, 0x0, 0x7235cc0, 0xc0011c34a0, 0xc0011d4580, 0x285)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000566fc0, 0x7258ba0, 0xc000130600, 0xc001dfe200, 0xc0015f2b70, 0xa649490, 0x0, 0x0, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0x522
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).handleStream(0xc000566fc0, 0x7258ba0, 0xc000130600, 0xc001dfe200, 0x0)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xd05
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000bdedb0, 0xc000566fc0, 0x7258ba0, 0xc000130600, 0xc001dfe200)
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0xa5
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: created by google.golang.org/grpc.(*Server).serveStreams.func1
2021-01-29T16:58:16.670+0100 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd
2021-01-29T16:58:16.675+0100 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/3.26.0/linux_amd64/terraform-provider-aws_v3.26.0_x5 pid=163969 error="exit status 2"
2021-01-29T16:58:16.675+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"

The ImageConfig can be null.

{
    ...
    "Configuration": {
        ...
        "ImageConfigResponse": {
            "Error": null,
            "ImageConfig": null
        },
    },
}
@wuurrd wuurrd requested a review from a team as a code owner January 29, 2021 16:12
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/lambda Issues and PRs that pertain to the lambda service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 29, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 29, 2021
@ewbankkit
Copy link
Contributor

@wuurrd Thanks for the contribution.
This is a duplicate of #17082 so I am going to close this PR and we can focus efforts on the linked one.

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jan 29, 2021
@ewbankkit
Copy link
Contributor

Relates: #17081.

@ewbankkit ewbankkit closed this Jan 29, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @wuurrd 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@wuurrd
Copy link
Author

wuurrd commented Jan 29, 2021

@ewbankkit excellent, although closing this one when that PR is without tests and without a proper explanation of why it occurs seems a bit strange?

@dspatoulas
Copy link

Agreed, @wuurrd #17082 needs to be updated. I was in a rush when I created it (we used a custom provider binary to fix deployment pipelines) and didn't get a chance to follow up until now.

I updated the description in the PR to match the contribution guidelines based on your example above. What is the best way to move over the unit test you wrote?

gdavison added a commit that referenced this pull request Feb 11, 2021
@ghost
Copy link

ghost commented Feb 28, 2021

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 as resolved and limited conversation to collaborators Feb 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/lambda Issues and PRs that pertain to the lambda service. size/XS Managed by automation to categorize the size of a PR. 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.

3 participants