Skip to content

Component providers panic when zero value pulumi.StringPtrOutputs are returned #397

@iwahbe

Description

@iwahbe

What happened?

While working with @jdavredbeard on a panicking provider, we discovered that returning a zero value pulumi.StringPtrOutput on a component would cause the framework to panic.

Example

Attempting to construct this resource will panic:

func provider() (p.Provider, error) {
	return infer.NewProviderBuilder().
		WithNamespace("examples").
		WithComponents(
			infer.ComponentF(func(ctx *pulumi.Context, name string, args DemoArgs, opts ...pulumi.ResourceOption) (*Repro, error) {
				var comp Repro
				err := ctx.RegisterComponentResource(p.GetTypeToken(ctx.Context()), name, &comp, opts...)
				if err != nil {
					return nil, err
				}
				comp.NilOutputString = pulumi.StringPtrOutput{}
				return &comp, nil
			}),
		).
		Build()
}

type DemoArgs struct{}

type Repro struct {
	pulumi.ResourceState

	NilOutputString pulumi.StringPtrOutput `pulumi:"s,optional"`
}

Output of pulumi about

v3.173.0

Additional context

6fad605 is a working reproduction. You can see the panic by checkout out 6fad605 and then running make examples/component-provider/test.

Contributing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact/panicThis bug represents a panic or unexpected crashkind/bugSome behavior is incorrect or out of spec

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions