{"record":{"id":"8603260a6b4461a8","repo":"hashicorp/terraform","slug":"failed-to-retrieve-lock-info-s","errorCode":null,"errorMessage":"failed to retrieve lock info: %s","messagePattern":"failed to retrieve lock info: (.+?)","errorType":"exception","errorClass":"statemgr.LockError","httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/azure/client.go","lineNumber":277,"sourceCode":"\t\tvalue := base64.StdEncoding.EncodeToString(info.Marshal())\n\t\tblob.MetaData[lockInfoMetaKey] = value\n\t}\n\n\topts := blobs.SetMetaDataInput{\n\t\tLeaseID:  &c.leaseID,\n\t\tMetaData: blob.MetaData,\n\t}\n\n\t_, err = c.giovanniBlobClient.SetMetaData(ctx, c.containerName, c.keyName, opts)\n\treturn err\n}\n\nfunc (c *RemoteClient) Unlock(id string) error {\n\tlockErr := &statemgr.LockError{}\n\n\tlockInfo, err := c.getLockInfo()\n\tif err != nil {\n\t\tlockErr.Err = fmt.Errorf(\"failed to retrieve lock info: %s\", err)\n\t\treturn lockErr\n\t}\n\tlockErr.Info = lockInfo\n\n\tif lockInfo.ID != id {\n\t\tlockErr.Err = fmt.Errorf(\"lock id %q does not match existing lock\", id)\n\t\treturn lockErr\n\t}\n\n\tc.leaseID = lockInfo.ID\n\tif err := c.writeLockInfo(nil); err != nil {\n\t\tlockErr.Err = fmt.Errorf(\"failed to delete lock info from metadata: %s\", err)\n\t\treturn lockErr\n\t}\n\n\tctx := newCtx()\n\t_, err = c.giovanniBlobClient.ReleaseLease(ctx, c.containerName, c.keyName, blobs.ReleaseLeaseInput{LeaseID: id})\n\tif err != nil {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/azure/client.go#L259-L295","documentation":"Raised in RemoteClient.Unlock (client.go:275-278). Unlock first calls getLockInfo to confirm the holder before releasing; if that fails — either a GetProperties data-plane error or the empty-metadata case (error 155) — this error wraps the cause in a LockError. The lock is not released.","triggerScenarios":"Produced at client.go:275-277 during 'terraform' teardown when c.getLockInfo() returns an error. Underlying cause is reported after the colon (GetProperties network failure, or 'blob metadata ... was empty').","commonSituations":"Transient data-plane error reading blob properties during unlock; the lock metadata is corrupt/empty (155); the blob was deleted while locked; network blip to the storage endpoint.","solutions":["Retry the Terraform command — transient GetProperties errors often clear","If the metadata is corrupt (155), break the lease: az storage blob lease break --account-name <account> -c <container> -b <key>","Verify network connectivity to the storage endpoint and that the blob still exists","Re-run 'terraform init' then the command"],"exampleFix":"# retry; if it keeps failing, break the lease\naz storage blob lease break \\\n  --account-name mystage --auth-mode login \\\n  -c tfstate -b \"prod.terraform.tfstate\"\n\nterraform init\nterraform apply","handlingStrategy":"retry","validationCode":"# Pre-check: can we read blob properties (GetProperties) before relying on unlock\naz storage blob show --account-name \"$ARM_STORAGE_ACCOUNT_NAME\" -c \"$ARM_CONTAINER_NAME\" -n \"$ARM_KEY\" >/dev/null 2>&1 \\\n  && echo \"OK: GetProperties works\" || echo \"WARN: cannot read blob -> unlock may fail (156)\"","typeGuard":null,"tryCatchPattern":"# Retry unlock on transient GetProperties failure; break lease as fallback\nsafe_unlock() {\n  for attempt in 1 2 3; do\n    if terraform force-unlock -force \"$1\" 2>/dev/null; then return 0; fi\n    sleep $((attempt*5))\n  done\n  az storage blob lease break --account-name \"$ARM_STORAGE_ACCOUNT_NAME\" -c \"$ARM_CONTAINER_NAME\" -n \"$ARM_KEY\"\n}","preventionTips":["Retry unlock on transient data-plane errors before escalating","If getLockInfo keeps failing, break the lease directly in Azure","Keep the storage endpoint reachable (firewall/VPN) during apply teardown"],"tags":["azure","state","locking","unlock","data-plane"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}