benbjohnson/litestream · error
put lock file: %w
Error message
put lock file: %w
What it means
writeLease's conditional PutObject failed with an error other than precondition-failed (which maps to LeaseExistsError). S3 rejected writing the lease object: connectivity, put permission, or bucket-level issues.
Source
Thrown at s3/leaser.go:257
input := &s3.PutObjectInput{
Bucket: aws.String(l.Bucket),
Key: aws.String(key),
Body: bytes.NewReader(data),
ContentType: aws.String("application/json"),
}
if etag == "" {
input.IfNoneMatch = aws.String("*")
} else {
input.IfMatch = aws.String(etag)
}
out, err := l.s3.PutObject(ctx, input)
if err != nil {
if isPreconditionFailed(err) {
return "", &litestream.LeaseExistsError{}
}
return "", fmt.Errorf("put lock file: %w", err)
}
newETag := ""
if out.ETag != nil {
newETag = *out.ETag
}
return newETag, nil
}
func isPreconditionFailed(err error) bool {
var apiErr smithy.APIError
if errors.As(err, &apiErr) {
code := apiErr.ErrorCode()
return code == "PreconditionFailed" || code == "412"
}
var respErr *smithy.OperationErrorView on GitHub (pinned to 4ed7a308f6)
Solutions
- Verify PutObject permission on the lease key
- Check S3 connectivity and retry acquisition
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at s3/leaser.go:257 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/fe3cbcace4a1a6cc.
Report an issue: GitHub.