fix: return error on conditional write for non existing object (#21550)

This commit is contained in:
M Alvee 2025-09-06 10:34:38 -07:00 committed by GitHub
parent 9fdbf6fe83
commit 558fc1c09c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -1277,6 +1277,11 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st
if err != nil && !isErrVersionNotFound(err) && !isErrObjectNotFound(err) && !isErrReadQuorum(err) {
return objInfo, err
}
// if object doesn't exist and not a replication request return error for conditional requests
if err != nil && !opts.ReplicationRequest {
return objInfo, err
}
}
// Validate input data size and it can never be less than -1.

View File

@ -414,12 +414,16 @@ func putOptsFromHeaders(ctx context.Context, hdr http.Header, metadata map[strin
if err != nil {
return ObjectOptions{}, err
}
return ObjectOptions{
op := ObjectOptions{
ServerSideEncryption: sseKms,
UserDefined: metadata,
MTime: mtime,
PreserveETag: etag,
}, nil
}
if _, ok := hdr[xhttp.MinIOSourceReplicationRequest]; ok {
op.ReplicationRequest = true
}
return op, nil
}
// default case of passing encryption headers and UserDefined metadata to backend
opts, err = getDefaultOpts(hdr, false, metadata)