Skip to content

Commit 5e4cfd4

Browse files
authored
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
1 parent d92915a commit 5e4cfd4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: BUG FIXES
2+
body: 'backend: Return conflicting lock info from HTTP backend instead of the lock that failed to be taken'
3+
time: 2026-02-10T11:39:30.00000-08:00

internal/backend/remote-state/http/client.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,18 @@ func (c *httpClient) Lock(info *statemgr.LockInfo) (string, error) {
105105
body, err := ioutil.ReadAll(resp.Body)
106106
if err != nil {
107107
return "", &statemgr.LockError{
108-
Info: info,
109-
Err: fmt.Errorf("HTTP remote state already locked, failed to read body"),
108+
Err: fmt.Errorf("HTTP remote state already locked, failed to read body"),
110109
}
111110
}
112111
existing := statemgr.LockInfo{}
113112
err = json.Unmarshal(body, &existing)
114113
if err != nil {
115114
return "", &statemgr.LockError{
116-
Info: info,
117-
Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"),
115+
Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"),
118116
}
119117
}
120118
return "", &statemgr.LockError{
121-
Info: info,
119+
Info: &existing,
122120
Err: fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID),
123121
}
124122
default:

0 commit comments

Comments
 (0)