pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
197 stars 43 forks source link

PF Configure Cross-tests fail when a `null` is present in an array #2555

Open iwahbe opened 5 days ago

iwahbe commented 5 days ago

The following test fails:

func TestConfigureNullInList(t *testing.T) {
    crosstests.Configure(t,
        schema.Schema{Attributes: map[string]schema.Attribute{
            "k": schema.ListAttribute{Optional: true, ElementType: types.StringType},
        }},
        map[string]cty.Value{
            "k": cty.ListVal([]cty.Value{
                cty.NullVal(cty.String),
                cty.StringVal("another-value"),
            }),
        },
    )
}

Generated HCL is:

provider "test" {
  k = [null, "another-value"]
}

resource "test_res" "res" {}

Generated Pulumi YAML is:

backend:
    url: file://./data
name: project
resources:
    p:
        properties:
            ks:
                - null
                - another-value
        type: pulumi:providers:test
runtime: yaml

Discovered as part of https://github.com/pulumi/pulumi-terraform-bridge/pull/2552

iwahbe commented 5 days ago

It looks like the same bug manifests in sets.

t0yv0 commented 4 days ago

I have a vague memory we drop nulls from within arrays historically but I can't quite find a quick reference.

iwahbe commented 4 days ago

I have a vague memory we drop nulls from within arrays historically but I can't quite find a quick reference.

We do, but TF doesn't. That's what causes the cross-test failure.

By "we", do you mean the engine/yaml or the bridge?

t0yv0 commented 3 days ago

I vaguely recall it's in the bridge, but I'm not 100% sure. It might be good to find out but I suspect once we do find out the preference would be to carry this behavior forward as "this is how bridged providers work" since there must have been reason of introducing it. Maybe not.. Either way does not seem like this issue has a lot of customer impact. Good to keep around, we can cross-link impact if we find it.