Skip to content

Comments

backend/http: Return existing lock info from backend on conflict#38144

Merged
SarahFrench merged 3 commits intohashicorp:mainfrom
nicholasngai:patch-1
Feb 18, 2026
Merged

backend/http: Return existing lock info from backend on conflict#38144
SarahFrench merged 3 commits intohashicorp:mainfrom
nicholasngai:patch-1

Conversation

@nicholasngai
Copy link
Contributor

Hi folks! We return info right now from the HTTP state backend which is the info of the lock we are trying to acquire, whereas the LockError generally indicates that we want to return the lock that is currently being held (that we are conflicting with). This PR is a 1-liner change to do this instead.

@nicholasngai nicholasngai requested a review from a team as a code owner February 10, 2026 19:35
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Feb 10, 2026

CLA assistant check
All committers have signed the CLA.

@nicholasngai nicholasngai changed the title Return existing lock info from http state backend on conflict backend: Return existing lock info from http state backend on conflict Feb 10, 2026
@nicholasngai nicholasngai changed the title backend: Return existing lock info from http state backend on conflict backend/http: Return existing lock info from http state backend on conflict Feb 10, 2026
@nicholasngai nicholasngai changed the title backend/http: Return existing lock info from http state backend on conflict backend/http: Return existing lock info from backend on conflict Feb 10, 2026
@crw
Copy link
Contributor

crw commented Feb 11, 2026

Thanks for this submission! Per the Contributing.md, the maintainers as a matter of policy are generally not accepting changes to backends, however I will raise this one in triage as it seems like a fairly straightforward fix. Thanks!

@nicholasngai
Copy link
Contributor Author

Thanks for the info! I actually am not sure I understand—does this mean that the maintainers would rather re-create this change themselves rather than merge in this PR?

@crw
Copy link
Contributor

crw commented Feb 13, 2026

@nicholasngai No, there is no problem accepting the contribution, it is more that the backends are basically frozen in terms of changes. However, before I say anything definitive let me raise this in triage (next week) and get back to you.

@nicholasngai
Copy link
Contributor Author

Sounds good! Thanks!

@SarahFrench SarahFrench self-assigned this Feb 18, 2026
SarahFrench added a commit that referenced this pull request Feb 18, 2026
… backend. Revert changes from #38144 to show that the test fails.
Copy link
Member

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nicholasngai, thanks for identifying this issue! It makes sense that the error should report the existing lock, like in the kubernetes backend. From surrounding code it looks like this was the intention by the original author.

I'd like there to be more tests covering this change. However, testing for backends isn't a well documented part of the codebase, due to reasons Craig has mentioned, and I don't want to lump you with a tough task. I've got a test prepared in #38192 and I can merge that, along with a small tweak to the changelog entry.

@@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body: 'backend: Return conflicting lock info from HTTP backend instead of the lock that failed to be taken'
body: 'backend/http: Return conflicting lock info from HTTP backend instead of the lock that failed to be taken'
custom:
Issue: "38144"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sharing this here but it'll be addressed in the PR I mentioned. Usually in change log entries we include the issue number (or PR number if there's no issue) as this allows the final generated changelog to link here.

@SarahFrench SarahFrench merged commit 5e4cfd4 into hashicorp:main Feb 18, 2026
10 of 11 checks passed
SarahFrench added a commit that referenced this pull request Feb 18, 2026
… backend. Revert changes from #38144 to show that the test fails.
@nicholasngai nicholasngai deleted the patch-1 branch February 18, 2026 18:31
@nicholasngai
Copy link
Contributor Author

Awesome, thanks everyone! 😄

SarahFrench added a commit that referenced this pull request Feb 18, 2026
* test: Update TestHTTPBackend so it can be created with pre-existing lock info inside it. This will be used for tests that want to assert the lock info returned with lock errors.

* test: Add a test asserting data returned in lock errors from the http backend.

* chore: Replace use of `io/ioutil` in http backend

* chore: Update changelog entry to link to the original PR #38144

* test: Improve test code comments
@SarahFrench SarahFrench removed their assignment Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants