Merge pull request #1728 from versity/sis/get-object-empty-tagging

fix: removes the NoSuchTagSet error in GetObjectTagging
This commit is contained in:
Ben McClelland
2026-01-03 20:51:08 -08:00
committed by GitHub
5 changed files with 29 additions and 11 deletions
+10 -6
View File
@@ -3779,10 +3779,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
}
@@ -3859,10 +3859,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
}
@@ -4084,10 +4084,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
}
@@ -4868,6 +4868,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 {
+1 -1
View File
@@ -18,7 +18,7 @@ check_tags_empty() {
if ! check_param_count_v2 "command type" 1 $#; then
return 1
fi
if [[ $1 == 'aws' ]]; then
if [ "$1" == 'aws' ] || [ "$1" == 's3api' ]; then
# shellcheck disable=SC2154
if [[ $tags == "" ]]; then
return 0
+7 -2
View File
@@ -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
})
}
+1
View File
@@ -779,6 +779,7 @@ func TestFullFlow(ts *TestState) {
TestDeleteObjects(ts)
TestCopyObject(ts)
TestPutObjectTagging(ts)
TestGetObjectTagging(ts)
TestDeleteObjectTagging(ts)
TestCreateMultipartUpload(ts)
TestUploadPart(ts)
+10 -2
View File
@@ -3419,12 +3419,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))
}