{"record":{"id":"6bbc6e2a9a55006a","repo":"hashicorp/terraform","slug":"failed-to-retrieve-lock-information-from-oci-objec","errorCode":null,"errorMessage":"Failed to retrieve lock information from OCI Object Storage: %w","messagePattern":"Failed to retrieve lock information from OCI Object Storage: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oci/client.go","lineNumber":331,"sourceCode":"\t}\n\tlockByteData, err := io.ReadAll(getResponse.Content)\n\tif err != nil {\n\t\treturn nil, *getResponse.ETag, fmt.Errorf(\"failed to read existing lock file content: %w\", err)\n\t}\n\tlockInfo := &statemgr.LockInfo{}\n\tif err := json.Unmarshal(lockByteData, lockInfo); err != nil {\n\t\treturn lockInfo, \"\", fmt.Errorf(\"failed to unmarshal JSON data into LockInfo struct: %w\", err)\n\t}\n\treturn lockInfo, *getResponse.ETag, nil\n}\nfunc (c *RemoteClient) Unlock(id string) error {\n\tctx := context.TODO()\n\tlogger := logWithOperation(\"unlock-state-file\").Named(c.lockFilePath)\n\tlogger.Info(\"unlocking remote state\")\n\tlockInfo, etag, err := c.getLockInfo(ctx)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to retrieve lock information from OCI Object Storage: %w\", err)\n\t}\n\t// Verify that the provided lock ID matches the lock ID of the retrieved lock file.\n\tif lockInfo.ID != id {\n\t\treturn &statemgr.LockError{\n\t\t\tInfo: lockInfo,\n\t\t\tErr:  fmt.Errorf(\"lock ID '%s' does not match the existing lock ID '%s'\", id, lockInfo.ID),\n\t\t}\n\t}\n\n\tdeleteRequest := objectstorage.DeleteObjectRequest{\n\t\tNamespaceName: common.String(c.namespace),\n\t\tObjectName:    common.String(c.lockFilePath),\n\t\tBucketName:    common.String(c.bucketName),\n\t\tIfMatch:       common.String(etag),\n\t\tRequestMetadata: common.RequestMetadata{\n\t\t\tRetryPolicy: getDefaultRetryPolicy(),\n\t\t},\n\t}","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/oci/client.go#L313-L349","documentation":"Raised in Unlock as the outer wrap over any failure returned by getLockInfo (errors 307/308/309). Unlock must read and parse the existing lock file before it can verify the ID and issue the conditional DeleteObject, so any failure to retrieve or parse lock information surfaces through this message.","triggerScenarios":"Unlock calls getLockInfo (client.go:328) which returns a non-nil error: GetObject fails (307), body read fails (308), or JSON unmarshal fails (309). The wrapped %w carries the specific sub-cause.","commonSituations":"Running 'terraform force-unlock'/'terraform unlock' when the lock file is missing, unreadable, or corrupt; IAM lacking read on the bucket at unlock time; transient read/parse failure.","solutions":["Unwrap the error to see whether it is 307 (get), 308 (read), or 309 (unmarshal) and follow that sub-error's fix.","For a missing lock file (404 under the wrap), the lock is already gone — verify with 'oci os object list --prefix <lockfile>' and clear any stale local state.","For a corrupt lock file, follow the unmarshal fix: inspect/delete the lock object once you confirm no real holder exists.","Re-run the unlock after fixing the underlying read/parse issue."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Probe lock file presence before attempting a full Unlock:\n//   oci os object head --namespace <ns> --bucket-name <b> --name <lockfile>\n// If absent, skip Unlock (nothing to release).","typeGuard":"// Unwrap to find the specific sub-cause (307/308/309):\nvar se common.ServiceError\nif errors.As(err, &se) && se.GetHTTPStatusCode() == 404 { /* no lock -> already unlocked */ }","tryCatchPattern":"lockInfo, etag, err := c.getLockInfo(ctx)\nif err != nil {\n    return fmt.Errorf(\"Failed to retrieve lock information from OCI Object Storage: %w\", err)\n}","preventionTips":["Before unlock, confirm a lock file actually exists.","Fix the underlying read/parse issue (307/308/309) first.","Retry transient retrieval failures."],"tags":["oci","object-storage","unlock","locking","terraform-state"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}