GetPolicyDocumentOutput panics instead of returning error
See original GitHub issueHello!
- Vote on this issue by adding a 👍 reaction
- To contribute a fix for this issue, leave a comment (and link to your pull request, if you’ve opened one already)
Issue details
This is a problematic line: https://github.com/pulumi/pulumi-aws/blob/f73d82bf022793a85cdd5bf7ac55638b64740cb9/sdk/go/aws/iam/getPolicyDocument.go#L141
(expanded below)
func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) {
args := v.(GetPolicyDocumentArgs)
r, err := GetPolicyDocument(ctx, &args, opts...)
return *r, err
}).(GetPolicyDocumentResultOutput)
}
if GetPolicyDocument
returns nil, <error here>
, then *r
will result in a panic
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1726ecf]
Steps to reproduce
_ = iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
iam.GetPolicyDocumentStatementArgs{
Actions: pulumi.StringArray{
pulumi.String("sts:AssumeRoleWithWebIdentity"),
},
Conditions: iam.GetPolicyDocumentStatementConditionArray{
iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("StringLike"),
Values: pulumi.StringArray{
pulumi.Sprintf("repo:%s/%s:*", "mytestorg", "mytestrepo"),
},
Variable: pulumi.String("token.actions.githubusercontent.com:sub"),
},
},
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
iam.GetPolicyDocumentStatementPrincipalArgs{
Identifiers: pulumi.StringArray{
pulumi.String("arn:aws:iam::12345678:oidc-provider/token.actions.githubusercontent.com"),
},
Type: pulumi.String("Federated"),
},
},
},
},
})
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x17240af]
goroutine 23 [running]:
github.com/pulumi/pulumi-aws/sdk/v4/go/aws/iam.GetPolicyDocumentOutput.func1({0x18fe240?, 0xc0005a4380})
/Users/wmcnamee/.asdf/installs/golang/1.18/packages/pkg/mod/github.com/pulumi/pulumi-aws/sdk/v4@v4.38.1/go/aws/iam/getPolicyDocument.go:356 +0x18f
reflect.Value.call({0x181b940?, 0xc000580480?, 0x100ea45?}, {0x197129f, 0x4}, {0xc00050e018, 0x1, 0xc0005b8240?})
/Users/wmcnamee/.asdf/installs/golang/1.18/go/src/reflect/value.go:556 +0x845
Note that the line numbers don’t match up with the source code (in this repo), but here’s a screenshot from the vendored code:
Expected: to get a human readable error Actual: panic and nil pointer exception
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
aws.iam.getPolicyDocument - Pulumi
Documentation for the aws.iam.getPolicyDocument function with examples, input properties, output properties, and supporting types.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ghostsquad Thank you again for noticing and reporting!
We verified it’s still an issue and are working on a fix. The issue is in pulumi/pulumi codegen, which is how these files get created, and once we ship that fix, on the next release of this provider this issue should be resolved.
https://github.com/pulumi/pulumi-aws/blob/master/sdk/go/aws/iam/getPolicyDocument.go#L215 the fix seems to be applied on master. Mind letting us know which version of the pulumi-aws Go SDK you are using so we can repro? 🙇