{"record":{"id":"2821712689c5e623","repo":"hashicorp/terraform","slug":"lock-id-q-does-not-match-existing-lock-id-s-s-282171","errorCode":null,"errorMessage":"lock ID %q does not match existing lock ID \"%s/%s\"","messagePattern":"lock ID %q does not match existing lock ID \"(.+?)/(.+?)\"","errorType":"validation","errorClass":"statemgr.LockError","httpStatus":null,"severity":"error","filePath":"internal/cloud/state.go","lineNumber":503,"sourceCode":"\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\t// This will not be retried\n\t\t\t\treturn &errorUnlockFailed{innerError: err}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\n\t\tif err != nil {\n\t\t\tlockErr.Err = err\n\t\t\treturn lockErr\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// Verify the optional force-unlock lock ID.\n\tif s.organization+\"/\"+s.workspace.Name != id {\n\t\tlockErr.Err = fmt.Errorf(\n\t\t\t\"lock ID %q does not match existing lock ID \\\"%s/%s\\\"\",\n\t\t\tid,\n\t\t\ts.organization,\n\t\t\ts.workspace.Name,\n\t\t)\n\t\treturn lockErr\n\t}\n\n\t// Force unlock the workspace.\n\t_, err := s.tfeClient.Workspaces.ForceUnlock(ctx, s.workspace.ID)\n\tif err != nil {\n\t\tlockErr.Err = err\n\t\treturn lockErr\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/state.go#L485-L521","documentation":"In Unlock's force-unlock path (when there is no internal s.lockInfo), the caller must pass the string \"<organization>/<workspace-name>\" as the id. If the provided id does not equal that, the force-unlock is refused.","triggerScenarios":"Unlock is called on the force-unlock path with an arbitrary or wrongly-formatted id (e.g. a UUID instead of org/workspace), or targeting the wrong workspace.","commonSituations":"Constructing the lock ID manually and getting the format or org/workspace wrong, or pointing at a different workspace than the one locked.","solutions":["Pass exactly \"<organization>/<workspace-name>\" as the lock ID for force-unlock.","Verify the organization and workspace names in the backend configuration.","Use terraform force-unlock \"<org>/<workspace>\" from the CLI."],"exampleFix":"// before: wrong format for force-unlock id\nstate.Unlock(\"some-uuid\")\n\n// after: use org/workspace as the force-unlock id\nstate.Unlock(s.organization + \"/\" + s.workspace.Name)","handlingStrategy":"validation","validationCode":"// Construct the expected force-unlock ID and validate it\nexpected := organization + \"/\" + workspace.Name\nif id != expected {\n    return fmt.Errorf(\"force-unlock id must be %q, got %q\", expected, id)\n}","typeGuard":null,"tryCatchPattern":"if err := state.Unlock(id); err != nil {\n    var lockErr *statemgr.LockError\n    if errors.As(err, &lockErr) && strings.Contains(lockErr.Err.Error(), \"does not match existing lock ID\") {\n        // retry with the correct org/workspace id\n    }\n}","preventionTips":["Use org/workspace (not a UUID) for force-unlock","Verify org and workspace names from the backend config","Prefer the normal unlock path when lock info is available"],"tags":["locking","force-unlock","programming-error"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}