Ensure we have an import error before using in import path (#5884)

Without this, we can panic
This commit is contained in:
Paul Stack 2020-12-08 00:43:35 +00:00 committed by GitHub
parent f81a4d28a5
commit 4f5b3c8522
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -2,7 +2,9 @@ CHANGELOG
=========
## HEAD (Unreleased)
_(none)_
- Fix a problem where `pulumi import` could panic on an import error due to missing error message.
[#5884](https://github.com/pulumi/pulumi/pull/5884)
## 2.15.3 (2020-12-07)

View file

@ -456,7 +456,7 @@ func (ex *deploymentExecutor) importResources(callerCtx context.Context, opts Op
canceled := callerCtx.Err() != nil
if res != nil || stepExec.Errored() {
if res.Error() != nil {
if res != nil && res.Error() != nil {
ex.reportExecResult(fmt.Sprintf("failed: %s", res.Error()), preview)
} else {
ex.reportExecResult("failed", preview)