From 188ea61a12807ad9516e69e960aafb37755cb553 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 15 Mar 2021 16:33:31 -0500 Subject: [PATCH] Fix duplicate default state The default state is already explicitly added to the result slice. Added a guard to prevent it being added a second time. Fixes https://github.com/hashicorp/terraform/issues/28098 --- backend/remote-state/etcdv3/backend_state.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/remote-state/etcdv3/backend_state.go b/backend/remote-state/etcdv3/backend_state.go index 1b8b1882e..1f514a8f4 100644 --- a/backend/remote-state/etcdv3/backend_state.go +++ b/backend/remote-state/etcdv3/backend_state.go @@ -23,7 +23,9 @@ func (b *Backend) Workspaces() ([]string, error) { result := make([]string, 1, len(res.Kvs)+1) result[0] = backend.DefaultStateName for _, kv := range res.Kvs { - result = append(result, strings.TrimPrefix(string(kv.Key), b.prefix)) + if strings.TrimPrefix(string(kv.Key), b.prefix) != backend.DefaultStateName { + result = append(result, strings.TrimPrefix(string(kv.Key), b.prefix)) + } } sort.Strings(result[1:])