From 9323d4fa9da494b0cda687f1266e9a2e609cf2fd Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 5 Jan 2023 10:38:36 +0800 Subject: [PATCH] Don't push state if there is no state to push (#327) This might happen when all the resources failed to import with "--continue". --- internal/meta/base_meta.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/meta/base_meta.go b/internal/meta/base_meta.go index dd43880..c70a613 100644 --- a/internal/meta/base_meta.go +++ b/internal/meta/base_meta.go @@ -239,6 +239,11 @@ func (meta *baseMeta) ParallelImport(items []*ImportItem) { func (meta baseMeta) PushState() error { ctx := context.TODO() + // Don't push state if there is no state to push. This might happen when all the resources failed to import with "--continue". + if len(meta.baseState) == 0 { + return nil + } + // Ensure there is no out of band change on the base state baseState, err := meta.tf.StatePull(ctx) if err != nil {