diff --git a/storage/bucket.go b/storage/bucket.go index 5601357c9b2b..43161f783825 100644 --- a/storage/bucket.go +++ b/storage/bucket.go @@ -1341,8 +1341,10 @@ func (ua *BucketAttrsToUpdate) toRawBucket() *raw.Bucket { } if ua.SoftDeletePolicy != nil { if ua.SoftDeletePolicy.RetentionDuration == 0 { - rb.NullFields = append(rb.NullFields, "SoftDeletePolicy") - rb.SoftDeletePolicy = nil + rb.SoftDeletePolicy = &raw.BucketSoftDeletePolicy{ + RetentionDurationSeconds: 0, + ForceSendFields: []string{"RetentionDurationSeconds"}, + } } else { rb.SoftDeletePolicy = ua.SoftDeletePolicy.toRawSoftDeletePolicy() } diff --git a/storage/bucket_test.go b/storage/bucket_test.go index 06cec765905d..f1bd45e52775 100644 --- a/storage/bucket_test.go +++ b/storage/bucket_test.go @@ -479,7 +479,10 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) { } got = au3.toRawBucket() want = &raw.Bucket{ - NullFields: []string{"RetentionPolicy", "Encryption", "Logging", "Website", "SoftDeletePolicy"}, + NullFields: []string{"RetentionPolicy", "Encryption", "Logging", "Website"}, + SoftDeletePolicy: &raw.BucketSoftDeletePolicy{ + ForceSendFields: []string{"RetentionDurationSeconds"}, + }, } if msg := testutil.Diff(got, want); msg != "" { t.Error(msg)