From 5e4cfd42fae3a0a921b658742b42e8a151b20b24 Mon Sep 17 00:00:00 2001 From: Nicholas Ngai Date: Wed, 18 Feb 2026 09:00:54 -0800 Subject: [PATCH] backend/http: Return existing lock info from backend on conflict (#38144) * Return existing lock info from http state backend on conflict * Remove info from LockError if failed to read or unmarshal * Add change to .changes --- .changes/v1.15/BUG FIXES-20260210-113930.yaml | 3 +++ internal/backend/remote-state/http/client.go | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 .changes/v1.15/BUG FIXES-20260210-113930.yaml diff --git a/.changes/v1.15/BUG FIXES-20260210-113930.yaml b/.changes/v1.15/BUG FIXES-20260210-113930.yaml new file mode 100644 index 0000000000..5e3428f3f5 --- /dev/null +++ b/.changes/v1.15/BUG FIXES-20260210-113930.yaml @@ -0,0 +1,3 @@ +kind: BUG FIXES +body: 'backend: Return conflicting lock info from HTTP backend instead of the lock that failed to be taken' +time: 2026-02-10T11:39:30.00000-08:00 diff --git a/internal/backend/remote-state/http/client.go b/internal/backend/remote-state/http/client.go index 7be30f9d15..1236b018bd 100644 --- a/internal/backend/remote-state/http/client.go +++ b/internal/backend/remote-state/http/client.go @@ -105,20 +105,18 @@ func (c *httpClient) Lock(info *statemgr.LockInfo) (string, error) { body, err := ioutil.ReadAll(resp.Body) if err != nil { return "", &statemgr.LockError{ - Info: info, - Err: fmt.Errorf("HTTP remote state already locked, failed to read body"), + Err: fmt.Errorf("HTTP remote state already locked, failed to read body"), } } existing := statemgr.LockInfo{} err = json.Unmarshal(body, &existing) if err != nil { return "", &statemgr.LockError{ - Info: info, - Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"), + Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"), } } return "", &statemgr.LockError{ - Info: info, + Info: &existing, Err: fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID), } default: