Skip to content

Conversation

@ryancragun
Copy link

This was discovered when using gohcl to decode a block that has attributes that are set to null.

panic: WithoutOptionalAttributesDeep does not support the given type

goroutine 46 [running]:
github.com/zclconf/go-cty/cty.Type.WithoutOptionalAttributesDeep({{0x0?, 0x0?}})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/type.go:152 +0x565
github.com/zclconf/go-cty/cty/convert.conversionObjectToObject.func1({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}}, {0x0, 0x0, 0x0})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion_object.go:86 +0x3a5
github.com/zclconf/go-cty/cty/convert.getConversion.func1({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}}, {0x0, 0x0, 0x0})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:57 +0x2b3
github.com/zclconf/go-cty/cty/convert.GetConversionUnsafe.retConversion.func1({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:199 +0x34
github.com/zclconf/go-cty/cty/convert.Convert({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}}, {{0x197f548?, 0xc0006288b0?}})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/public.go:51 +0x151
github.com/hashicorp/hcl/v2/gohcl.DecodeExpression({0x197f698, 0xc0003b27e0}, 0x197f580?, {0x1720c40, 0xc0001cdcf8})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/gohcl/decode.go:299 +0xb0
github.com/hashicorp/enos/internal/flightplan.(*Scenario).decodeAndValidateTerraformCLIAttribute(0xc0001cdce0, 0xc0000cac00, 0xc001ac7998)
  ¦ ¦ ¦ /home/runner/actions-runner/_work/enos/enos/internal/flightplan/scenario.go:349 +0x610
github.com/hashicorp/enos/internal/flightplan.(*Scenario).decode(...)
  ¦ ¦ ¦ /home/runner/actions-runner/_work/enos/enos/internal/flightplan/scenario.go:187
github.com/hashicorp/enos/internal/flightplan.(*ScenarioDecoder).decodeScenario(0xc0005b36c8, 0xc000bc8bd0, 0xc00085cf70)
panic: WithoutOptionalAttributesDeep does not support the given type

This was discovered when using `gohcl` to decode a block that has attributes that are set to null.

```
panic: WithoutOptionalAttributesDeep does not support the given type

goroutine 46 [running]:
github.com/zclconf/go-cty/cty.Type.WithoutOptionalAttributesDeep({{0x0?, 0x0?}})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/type.go:152 +0x565
github.com/zclconf/go-cty/cty/convert.conversionObjectToObject.func1({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}}, {0x0, 0x0, 0x0})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion_object.go:86 +0x3a5
github.com/zclconf/go-cty/cty/convert.getConversion.func1({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}}, {0x0, 0x0, 0x0})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:57 +0x2b3
github.com/zclconf/go-cty/cty/convert.GetConversionUnsafe.retConversion.func1({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:199 +0x34
github.com/zclconf/go-cty/cty/convert.Convert({{{0x197f548?, 0xc0006ff170?}}, {0x1766d40?, 0xc0005b9da0?}}, {{0x197f548?, 0xc0006288b0?}})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/zclconf/[email protected]/cty/convert/public.go:51 +0x151
github.com/hashicorp/hcl/v2/gohcl.DecodeExpression({0x197f698, 0xc0003b27e0}, 0x197f580?, {0x1720c40, 0xc0001cdcf8})
  ¦ ¦ ¦ /home/runner/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/gohcl/decode.go:299 +0xb0
github.com/hashicorp/enos/internal/flightplan.(*Scenario).decodeAndValidateTerraformCLIAttribute(0xc0001cdce0, 0xc0000cac00, 0xc001ac7998)
  ¦ ¦ ¦ /home/runner/actions-runner/_work/enos/enos/internal/flightplan/scenario.go:349 +0x610
github.com/hashicorp/enos/internal/flightplan.(*Scenario).decode(...)
  ¦ ¦ ¦ /home/runner/actions-runner/_work/enos/enos/internal/flightplan/scenario.go:187
github.com/hashicorp/enos/internal/flightplan.(*ScenarioDecoder).decodeScenario(0xc0005b36c8, 0xc000bc8bd0, 0xc00085cf70)
panic: WithoutOptionalAttributesDeep does not support the given type
```

Signed-off-by: Ryan Cragun <[email protected]>
@ryancragun
Copy link
Author

I suppose we could just continue through the loop and set nothing, though I knowing that something was set and set to null can be useful.

ryancragun added a commit to hashicorp/enos that referenced this pull request Oct 5, 2023
…112)

Use a fork of `go-cty` that fixes a panic when decoding a Terraform settings
that have attributes set to `null`.

After it has been fixed upstream[0] we should go back to relying on
on the upstream stable release.

[0] zclconf/go-cty#171

Signed-off-by: Ryan Cragun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant