Ensure the CLI doesn't panic when trying to build a graph for a stack with no snapshot (#5678)

Fixes: #4952
This commit is contained in:
Paul Stack 2020-11-04 17:33:39 +00:00 committed by GitHub
parent 4d96994fd1
commit a42bafcf5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -11,6 +11,9 @@ CHANGELOG
- [cli] Ensure that the CLI doesn't panic when using pulumi watch and using ComponentResources with non-standard naming
[#5675](https://github.com/pulumi/pulumi/pull/5675)
- [cli] Ensure that the CLI doesn't panic when trying to assemble a graph on a stack that has no snapshot available
[#5678](https://github.com/pulumi/pulumi/pull/5678)
## 2.12.1 (2020-10-23)

View file

@ -15,6 +15,7 @@
package main
import (
"github.com/pkg/errors"
"os"
"strings"
@ -65,6 +66,11 @@ func newStackGraphCmd() *cobra.Command {
return err
}
// This will prevent a panic when trying to assemble a dependencyGraph when no snapshot is found
if snap == nil {
return errors.Errorf("unable to find snapshot for stack %q", stackName)
}
dg := makeDependencyGraph(snap)
file, err := os.Create(args[0])
if err != nil {