From 06a45124b1755756e42e16105202fe8979036ffe Mon Sep 17 00:00:00 2001 From: niksis02 Date: Fri, 2 Jan 2026 23:31:35 +0400 Subject: [PATCH] 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. --- backend/posix/posix.go | 16 ++++++++++------ tests/integration/GetObjectTagging.go | 9 +++++++-- tests/integration/group-tests.go | 1 + tests/integration/versioning.go | 12 ++++++++++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/backend/posix/posix.go b/backend/posix/posix.go index 54cce0d8..4418a216 100644 --- a/backend/posix/posix.go +++ b/backend/posix/posix.go @@ -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 { diff --git a/tests/integration/GetObjectTagging.go b/tests/integration/GetObjectTagging.go index 2805a247..d1893b2a 100644 --- a/tests/integration/GetObjectTagging.go +++ b/tests/integration/GetObjectTagging.go @@ -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 }) } diff --git a/tests/integration/group-tests.go b/tests/integration/group-tests.go index bb73b6e2..2231a3d8 100644 --- a/tests/integration/group-tests.go +++ b/tests/integration/group-tests.go @@ -778,6 +778,7 @@ func TestFullFlow(ts *TestState) { TestDeleteObjects(ts) TestCopyObject(ts) TestPutObjectTagging(ts) + TestGetObjectTagging(ts) TestDeleteObjectTagging(ts) TestCreateMultipartUpload(ts) TestUploadPart(ts) diff --git a/tests/integration/versioning.go b/tests/integration/versioning.go index bb70a082..c076576c 100644 --- a/tests/integration/versioning.go +++ b/tests/integration/versioning.go @@ -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)) }