{"record":{"id":"27812425c9282579","repo":"hashicorp/terraform","slug":"lock-file-s-not-exists","errorCode":null,"errorMessage":"lock file %s not exists","messagePattern":"lock file (.+?) not exists","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/cos/client.go","lineNumber":168,"sourceCode":"\tinfo, infoErr := c.lockInfo()\n\tif infoErr != nil {\n\t\tlockErr.Err = errors.Join(lockErr.Err, infoErr)\n\t} else {\n\t\tlockErr.Info = info\n\t}\n\n\treturn lockErr\n}\n\n// lockInfo returns LockInfo from lock file\nfunc (c *remoteClient) lockInfo() (*statemgr.LockInfo, error) {\n\texists, data, checksum, err := c.getObject(c.lockFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !exists {\n\t\treturn nil, fmt.Errorf(\"lock file %s not exists\", c.lockFile)\n\t}\n\n\tinfo := &statemgr.LockInfo{}\n\tif err := json.Unmarshal(data, info); err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo.ID = checksum\n\n\treturn info, nil\n}\n\n// getObject get remote object\nfunc (c *remoteClient) getObject(cosFile string) (exists bool, data []byte, checksum string, err error) {\n\trsp, err := c.cosClient.Object.Get(c.cosContext, cosFile, nil)\n\tif rsp == nil {\n\t\tlog.Printf(\"[DEBUG] getObject %s: error: %v\", cosFile, err)\n\t\terr = fmt.Errorf(\"failed to open file at %v: %v\", cosFile, err)","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/cos/client.go#L150-L186","documentation":"Raised by remoteClient.lockInfo() (cos/client.go:168) when the lock file object does not exist in COS (getObject reports exists==false). There is no lock metadata to read or release, so any lock-info-dependent operation cannot proceed.","triggerScenarios":"lockInfo() (called by Unlock and lockError) finds the lock file absent - typically because the lock was already released, manually deleted, or never created.","commonSituations":"Another process already unlocked the state; the lock file object was deleted out-of-band; trying to unlock a state that was never locked.","solutions":["Verify whether another run already released the lock; if so, the state is free to use.","If the tag lock remains, delete the tencentcloud-terraform-lock tag manually.","Re-run the terraform operation once the lock file and tag are both gone."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check lock file existence before relying on lock info\nexists, _, _, _ := c.getObject(c.lockFile)\nif !exists {\n    // no lock present; nothing to unlock\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Treat a missing lock file as 'already unlocked' rather than fatal\n_, err := c.lockInfo()\nif err != nil && strings.Contains(err.Error(), \"not exists\") {\n    return nil // lock already gone\n}","preventionTips":["Idempotently handle unlock - a missing lock file is usually fine.","Coordinate runs so only one process manages a lock at a time.","Do not delete the lock file out-of-band while a run is active."],"tags":["cos","tencentcloud","lock","lock-file","not-found"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}