From aaa897337d19ebc2428f7fd233de536a4112f2be Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 24 Nov 2023 17:14:40 +0000 Subject: [PATCH] serve s3: fix error handling for listing non-existent prefix - fixes #7455 Before this change serve s3 would return NoSuchKey errors when a non existent prefix was listed. This change fixes it to return an empty list like AWS does. This was discovered by the full integration tests. --- cmd/serve/s3/backend.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/serve/s3/backend.go b/cmd/serve/s3/backend.go index 55c63ce1b..305012f34 100644 --- a/cmd/serve/s3/backend.go +++ b/cmd/serve/s3/backend.go @@ -84,7 +84,10 @@ func (b *s3Backend) ListBucket(bucket string, prefix *gofakes3.Prefix, page gofa err = b.entryListR(bucket, path, remaining, prefix.HasDelimiter, response) } - if err != nil { + if err == gofakes3.ErrNoSuchKey { + // AWS just returns an empty list + response = gofakes3.NewObjectList() + } else if err != nil { return nil, err }