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.
go-tfe version
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:
Workspace locked by user example:
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:The error response is "workspace already unlocked" which is incorrect since the workspaces are still locked.
Additional Context
This is a similar issue to https://github.com/hashicorp/go-tfe/issues/236