diff --git a/api/handler/put_test.go b/api/handler/put_test.go index a96c28ea..889bdef6 100644 --- a/api/handler/put_test.go +++ b/api/handler/put_test.go @@ -379,6 +379,21 @@ func TestCreateBucket(t *testing.T) { createBucketAssertS3Error(hc, bktName, box2, s3errors.ErrBucketAlreadyExists) } +func TestCreateOldBucketPutVersioning(t *testing.T) { + hc := prepareHandlerContext(t) + hc.config.aclEnabled = true + bktName := "bkt-name" + + info := createBucket(hc, bktName) + settings, err := hc.tree.GetSettingsNode(hc.Context(), info.BktInfo) + require.NoError(t, err) + settings.OwnerKey = nil + err = hc.tree.PutSettingsNode(hc.Context(), info.BktInfo, settings) + require.NoError(t, err) + + putBucketVersioning(t, hc, bktName, true) +} + func TestCreateNamespacedBucket(t *testing.T) { hc := prepareHandlerContext(t) bktName := "bkt-name" diff --git a/pkg/service/tree/tree.go b/pkg/service/tree/tree.go index 50fc3114..ceacb1e6 100644 --- a/pkg/service/tree/tree.go +++ b/pkg/service/tree/tree.go @@ -1397,7 +1397,9 @@ func metaFromSettings(settings *data.BucketSettings) map[string]string { results[versioningKV] = settings.Versioning results[lockConfigurationKV] = encodeLockConfiguration(settings.LockConfiguration) results[cannedACLKV] = settings.CannedACL - results[ownerKeyKV] = hex.EncodeToString(settings.OwnerKey.Bytes()) + if settings.OwnerKey != nil { + results[ownerKeyKV] = hex.EncodeToString(settings.OwnerKey.Bytes()) + } return results }