nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ceph/ceph-csi
Pull request #2152 (2021-06-10 15:43:28)

Fix regression when no image features are provided (backport #2135)
This is an automatic backport of pull request #2135 done by [Mergify](https://mergify.io).


---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the [documentation](https://docs.mergify.io/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on `<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.io/) you can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.io/
</details>



Patch:
diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go
index e973f5847..1e3de150e 100644
--- a/internal/rbd/rbd_util.go
+++ b/internal/rbd/rbd_util.go
@@ -993,6 +993,13 @@ func genVolFromVolumeOptions(ctx context.Context, volOptions, credentials map[st
 }
 
 func (rv *rbdVolume) validateImageFeatures(imageFeatures string) error {
+	// It is possible for image features to be an empty string which
+	// the Go split function would return a single item array with
+	// an empty string, causing a failure when trying to validate
+	// the features.
+	if strings.TrimSpace(imageFeatures) == "" {
+		return nil
+	}
 	arr := strings.Split(imageFeatures, ",")
 	featureSet := sets.NewString(arr...)
 	for _, f := range arr {


Test patch:
diff --git a/internal/rbd/rbd_util_test.go b/internal/rbd/rbd_util_test.go
index b8122585a..166cb460b 100644
--- a/internal/rbd/rbd_util_test.go
+++ b/internal/rbd/rbd_util_test.go
@@ -51,6 +51,14 @@ func TestValidateImageFeatures(t *testing.T) {
 		isErr         bool
 		errMsg        string
 	}{
+		{
+			"",
+			&rbdVolume{
+				Mounter: rbdDefaultMounter,
+			},
+			false,
+			"",
+		},
 		{
 			"layering",
 			&rbdVolume{