Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlocking a workspace that is locked by a Team or User returns the wrong error #971

Closed
lucasmelin opened this issue Sep 12, 2024 · 0 comments · Fixed by #975
Closed

Unlocking a workspace that is locked by a Team or User returns the wrong error #971

lucasmelin opened this issue Sep 12, 2024 · 0 comments · Fixed by #975
Labels
bug Something isn't working

Comments

@lucasmelin
Copy link
Collaborator

go-tfe version

v1.65.0

Description

Attempting to unlock a workspace that is locked by a Team or different User returns an incorrect "workspace already unlocked" error, even though the workspace is still locked.

Testing plan

If a workspace is locked by a team or a different user, an attempt to unlock the workspace will fail with a "workspace already unlocked" error.

Expected Behavior

If calling via the API, the error response is "Unable to unlock workspace. The workspace is locked by Team ..." or "Unable to unlock workspace. The workspace is locked by User ...".

Workspace locked by team example:

curl \
--header "Authorization: Bearer $TFC_TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
https://app.terraform.io/api/v2/workspaces/ws-kdiy6M8U1KXqzdHJ/actions/unlock | jq .

{
  "errors": [
    {
      "status": "409",
      "title": "conflict",
      "detail": "Unable to unlock workspace. The workspace is locked by Team b4e6d384-ca3c-1b77-d1eb-dd276b9a4fd4 and may not be unlocked except by them."
    }
  ]
}

Workspace locked by user example:

curl \
--header "Authorization: Bearer $TFC_TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
https://app.terraform.io/api/v2/workspaces/ws-jHHoSeXBENvUqbSf/actions/unlock | jq .

{
  "errors": [
    {
      "status": "409",
      "title": "conflict",
      "detail": "Unable to unlock workspace. The workspace is locked by User foo and may not be unlocked except by them."
    }
  ]
}

The expected behavior is the the return message from Unlock() would more closely match the API response, and indicate that the workspace is still locked.

Actual Behavior

When calling Unlock() on these workspaces in either scenario using:

ws, err := client.Workspaces.Unlock(ctx, w.ID)

The error response is "workspace already unlocked" which is incorrect since the workspaces are still locked.

Additional Context

This is a similar issue to #236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant