From 7362e7ee3b6f51f7753dea4d539c95c94bc9524f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Mon, 25 May 2026 18:22:37 +0000 Subject: [PATCH] fix(snapshot): check duplicate name even when renaming to same name The SnapshotsAPITestCreateUpdate test expects that PUT /api/snapshots/:name with the same Name in the body returns a conflict error. The previous fix added 'b.Name != name' guards to skip the duplicate check when the name hasn't changed, but this broke the test which expects the old behavior: any existing name (including the snapshot's own current name) should be rejected as a duplicate. Remove the 'b.Name != name' condition from both the pre-task validation and the in-task duplicate check so the behavior matches the original. --- api/snapshot.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/snapshot.go b/api/snapshot.go index 1255eb4c..89787dac 100644 --- a/api/snapshot.go +++ b/api/snapshot.go @@ -340,7 +340,7 @@ func apiSnapshotsUpdate(c *gin.Context) { } // Pre-task validation of new name if provided - if b.Name != "" && b.Name != name { + if b.Name != "" { _, err = collection.ByName(b.Name) if err == nil { AbortWithJSONError(c, 409, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name)) @@ -362,8 +362,8 @@ func apiSnapshotsUpdate(c *gin.Context) { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err } - // Fresh duplicate check inside lock (if renaming) - if b.Name != "" && b.Name != name { + // Fresh duplicate check inside lock + if b.Name != "" { _, err := taskCollection.ByName(b.Name) if err == nil { return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name)