diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 5ecddce9..bdbc6b8e 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -1,3 +1,5 @@ ### Improvements ### Bug Fixes + +- Fix a panic when the compiler doesn't include the name attribute from the Pulumi.yaml. diff --git a/pkg/pulumiyaml/run.go b/pkg/pulumiyaml/run.go index 27fd5e0f..9ae8953a 100644 --- a/pkg/pulumiyaml/run.go +++ b/pkg/pulumiyaml/run.go @@ -72,10 +72,19 @@ func LoadFromCompiler(compiler string, workingDirectory string, env []string) (* if stdout.Len() != 0 { diags = append(diags, syntax.Warning(nil, fmt.Sprintf("compiler %v warnings: %v", name, stdout.String()), "")) } + templateStr := stdout.String() template, tdiags, err := LoadYAMLBytes(fmt.Sprintf("", name), []byte(templateStr)) diags.Extend(tdiags...) + if template.Name == nil { + uncompiledTemplate, _, err := LoadDir(workingDirectory) + if err != nil || uncompiledTemplate.Name == nil { + return nil, diags, errors.New("compiler did not produce a valid template") + } + template.Name = uncompiledTemplate.Name + } + return template, tdiags, err }