question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetPolicyDocumentOutput panics instead of returning error

See original GitHub issue

Hello!

  • 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:

image

Expected: to get a human readable error Actual: panic and nil pointer exception

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
guineveresaengercommented, Mar 23, 2022

@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.

0reactions
t0yv0commented, Aug 8, 2022

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? 🙇

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found