{"record":{"id":"631fec1fe51b6b2e","repo":"benbjohnson/litestream","slug":"decode-lock-file-w","errorCode":null,"errorMessage":"decode lock file: %w","messagePattern":"decode lock file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"s3/leaser.go","lineNumber":219,"sourceCode":"\nfunc (l *Leaser) readLease(ctx context.Context) (*litestream.Lease, string, error) {\n\tkey := l.lockKey()\n\n\tout, err := l.s3.GetObject(ctx, &s3.GetObjectInput{\n\t\tBucket: aws.String(l.Bucket),\n\t\tKey:    aws.String(key),\n\t})\n\tif err != nil {\n\t\tif isNotExists(err) || isNotFoundError(err) {\n\t\t\treturn nil, \"\", os.ErrNotExist\n\t\t}\n\t\treturn nil, \"\", fmt.Errorf(\"get lock file: %w\", err)\n\t}\n\tdefer out.Body.Close()\n\n\tvar lease litestream.Lease\n\tif err := json.NewDecoder(out.Body).Decode(&lease); err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"decode lock file: %w\", err)\n\t}\n\n\tetag := \"\"\n\tif out.ETag != nil {\n\t\tetag = *out.ETag\n\t}\n\tlease.ETag = etag\n\n\treturn &lease, etag, nil\n}\n\nfunc (l *Leaser) writeLease(ctx context.Context, lease *litestream.Lease, etag string) (string, error) {\n\tkey := l.lockKey()\n\n\tdata, err := json.Marshal(lease)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"marshal lock file: %w\", err)\n\t}","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/s3/leaser.go#L201-L237","documentation":"The lease JSON downloaded from S3 could not be decoded — the lock file object exists but does not contain valid litestream.Lease JSON. The lease file was manually written, truncated, or written by an incompatible version.","triggerScenarios":"Thrown at s3/leaser.go:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the malformed lease object from S3 and let litestream re-acquire","Ensure only compatible litestream versions share the lease path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}