mirror of
https://github.com/versity/versitygw.git
synced 2026-08-17 04:36:19 +00:00
fix: removes the NoSuchTagSet error in GetObjecTagging
Fixes #1686 GetObjectTagging previously returned a `NoSuchTagSet` error when no object tags were set. This has been fixed, and an empty tag set is now returned instead.
This commit is contained in:
+10
-6
@@ -3785,10 +3785,10 @@ func (p *Posix) GetObject(_ context.Context, input *s3.GetObjectInput) (*s3.GetO
|
||||
|
||||
var tagCount *int32
|
||||
tags, err := p.getAttrTags(bucket, object, versionId)
|
||||
if err != nil && !errors.Is(err, s3err.GetAPIError(s3err.ErrBucketTaggingNotFound)) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tags != nil {
|
||||
if len(tags) != 0 {
|
||||
tgCount := int32(len(tags))
|
||||
tagCount = &tgCount
|
||||
}
|
||||
@@ -3865,10 +3865,10 @@ func (p *Posix) GetObject(_ context.Context, input *s3.GetObjectInput) (*s3.GetO
|
||||
|
||||
var tagCount *int32
|
||||
tags, err := p.getAttrTags(bucket, object, versionId)
|
||||
if err != nil && !errors.Is(err, s3err.GetAPIError(s3err.ErrBucketTaggingNotFound)) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tags != nil {
|
||||
if len(tags) != 0 {
|
||||
tgCount := int32(len(tags))
|
||||
tagCount = &tgCount
|
||||
}
|
||||
@@ -4090,10 +4090,10 @@ func (p *Posix) HeadObject(ctx context.Context, input *s3.HeadObjectInput) (*s3.
|
||||
|
||||
var tagCount *int32
|
||||
tags, err := p.getAttrTags(bucket, object, versionId)
|
||||
if err != nil && !errors.Is(err, s3err.GetAPIError(s3err.ErrBucketTaggingNotFound)) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tags != nil {
|
||||
if len(tags) != 0 {
|
||||
tc := int32(len(tags))
|
||||
tagCount = &tc
|
||||
}
|
||||
@@ -4874,6 +4874,10 @@ func (p *Posix) getAttrTags(bucket, object, versionId string) (map[string]string
|
||||
return nil, s3err.GetAPIError(s3err.ErrNoSuchKey)
|
||||
}
|
||||
if errors.Is(err, meta.ErrNoSuchKey) {
|
||||
if object != "" {
|
||||
// return empty tag set for object tagging
|
||||
return tags, nil
|
||||
}
|
||||
return nil, s3err.GetAPIError(s3err.ErrBucketTaggingNotFound)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -48,14 +48,19 @@ func GetObjectTagging_unset_tags(s *S3Conf) error {
|
||||
return err
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err = s3client.GetObjectTagging(ctx, &s3.GetObjectTaggingInput{
|
||||
res, err := s3client.GetObjectTagging(ctx, &s3.GetObjectTaggingInput{
|
||||
Bucket: &bucket,
|
||||
Key: &obj,
|
||||
})
|
||||
cancel()
|
||||
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrBucketTaggingNotFound)); err != nil {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res.TagSet) != 0 {
|
||||
return fmt.Errorf("expected empty tag set, instead got %v", res.TagSet)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -778,6 +778,7 @@ func TestFullFlow(ts *TestState) {
|
||||
TestDeleteObjects(ts)
|
||||
TestCopyObject(ts)
|
||||
TestPutObjectTagging(ts)
|
||||
TestGetObjectTagging(ts)
|
||||
TestDeleteObjectTagging(ts)
|
||||
TestCreateMultipartUpload(ts)
|
||||
TestUploadPart(ts)
|
||||
|
||||
@@ -3400,12 +3400,20 @@ func Versioning_PutGetDeleteObjectTagging_success(s *S3Conf) error {
|
||||
}
|
||||
|
||||
ctx, cancel = context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err = s3client.GetObjectTagging(ctx, &s3.GetObjectTaggingInput{
|
||||
r, err := s3client.GetObjectTagging(ctx, &s3.GetObjectTaggingInput{
|
||||
Bucket: &bucket,
|
||||
Key: &obj,
|
||||
VersionId: versionId,
|
||||
})
|
||||
cancel()
|
||||
return checkApiErr(err, s3err.GetAPIError(s3err.ErrBucketTaggingNotFound))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(r.TagSet) != 0 {
|
||||
return fmt.Errorf("expected empty tag set, instead got %v", r.TagSet)
|
||||
}
|
||||
|
||||
return nil
|
||||
}, withVersioning(types.BucketVersioningStatusEnabled))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user