Merge pull request #1083 from versity/fix/headobject-versioning-not-allowed

fix: Changes HeadObject returned error type from MethodNotAllowed to …
This commit is contained in:
Ben McClelland
2025-02-24 15:33:01 -08:00
committed by GitHub
2 changed files with 18 additions and 4 deletions

View File

@@ -3632,10 +3632,14 @@ func (p *Posix) HeadObject(ctx context.Context, input *s3.HeadObjectInput) (*s3.
// if the specified object version is a delete marker, return MethodNotAllowed
if isDelMarker {
return &s3.HeadObjectOutput{
DeleteMarker: getBoolPtr(true),
LastModified: backend.GetTimePtr(fi.ModTime()),
}, s3err.GetAPIError(s3err.ErrMethodNotAllowed)
if versionId != "" {
return &s3.HeadObjectOutput{
DeleteMarker: getBoolPtr(true),
LastModified: backend.GetTimePtr(fi.ModTime()),
}, s3err.GetAPIError(s3err.ErrMethodNotAllowed)
} else {
return nil, s3err.GetAPIError(s3err.ErrNoSuchKey)
}
}
}

View File

@@ -14461,6 +14461,16 @@ func Versioning_HeadObject_delete_marker(s *S3Conf) error {
return err
}
ctx, cancel = context.WithTimeout(context.Background(), shortTimeout)
_, err = s3client.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: &bucket,
Key: &obj,
})
cancel()
if err := checkSdkApiErr(err, "NotFound"); err != nil {
return err
}
return nil
}, withVersioning(types.BucketVersioningStatusEnabled))
}