Skip to content

NullReferenceExceptions during targeted destroy #1057

Description

@jkerken

What happened?

Running a targeted destroy of resources of one provider causes NullReferenceExceptions in Kubernetes Custom Resources

Command used:
pulumi destroy --target '**azure-native:network:Subnet::**platform**' --run-program --target-dependents --skip-preview

Same behaviour not observed during normal up

Example

none

Output of pulumi about

'dotnet build -nologo D:\customers\spellslab\devspells-root\devops\DsRoot.Infrastructure\src' completed successfully
CLI
Version 3.248.0
Go Version go1.26.4
Go Compiler gc

Plugins
KIND NAME VERSION
resource azure-native 3.19.0
language dotnet unknown

Host
OS Microsoft Windows 11 Pro
Version 10.0.26200 Build 26200
Arch x86_64

This project is written in dotnet: executable='C:\Program Files\dotnet\dotnet.exe' version='8.0.422'

Found no pending operations associated with main

Backend
Name AlgoJk
URL azblob://state-state
User AzureAD\JanKerkenhoff
Organizations
Token type personal

Environment Variables:
Name Value
PULUMI_BACKEND_URL "azblob://state-state"

Dependencies:
NAME VERSION
JetBrains.Annotations 2025.2.4
StyleCop.Analyzers 1.2.0-beta.556

Pulumi locates its logs in C:\Users\JANKER~1\AppData\Local\Temp by default

Additional context

Oberserved the exception in this code:

        CustomResourceArgs issuerArgs = args.Namespace != null
            ? new IssuerArgs
            {
                Metadata = metadata,
                Spec = spec,
            }
            : new ClusterIssuerArgs
            {
                Metadata = metadata,
                Spec = spec,
            };

        var issuer = new Pulumi.Kubernetes.ApiExtensions.CustomResource(
            $"{name}-resource",
            issuerArgs,
            new CustomResourceOptions
            {
                Parent = this,
            });
        Issuer = new IssuerRef
        {
            Name = issuer.Metadata.Apply(m => m.Name), <--- accessing Name on Null MetaData
            Kind = Output.Create("Issuer"),
            Group = Output.Create("cert-manager.io"),
        };
    }

Offending resource type: "cert-manager.io/v1", "Issuer"
If your remove this, this happens at other places

debug.log

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

Labels

kind/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