nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: skupperproject/skupper
Pull request #1639 (2024-09-06 16:20:11)

fix client cleanup panic
Fixes https://github.com/skupperproject/skupper/issues/1628

Removes some effectively dead code left over from an iteration of development that was the root cause of a panic (closing a closed channel.)


Patch:
diff --git a/pkg/vanflow/eventsource/client.go b/pkg/vanflow/eventsource/client.go
index 39d4743b..990c269b 100644
--- a/pkg/vanflow/eventsource/client.go
+++ b/pkg/vanflow/eventsource/client.go
@@ -48,17 +48,9 @@ func NewClient(container session.Container, cfg ClientOptions) *Client {
 			slog.String("instance", cfg.Source.ID),
 		),
 	}
-	c.start()
 	return c
 }
 
-func (c *Client) start() {
-	c.lock.Lock()
-	defer c.lock.Unlock()
-	done := make(chan struct{})
-	c.cleanup = append(c.cleanup, func() { close(done) })
-}
-
 type HeartbeatMessageHandler func(vanflow.HeartbeatMessage)
 type RecordMessageHandler func(vanflow.RecordMessage)
 


Test patch:
diff --git a/pkg/vanflow/eventsource/client_test.go b/pkg/vanflow/eventsource/client_test.go
index b7bb6624..33db014f 100644
--- a/pkg/vanflow/eventsource/client_test.go
+++ b/pkg/vanflow/eventsource/client_test.go
@@ -87,6 +87,15 @@ func TestClient(t *testing.T) {
 		t.Error("expected client.Close() to promptly return")
 	}
 
+	func() {
+		defer func() {
+			if r := recover(); r != nil {
+				t.Errorf("client.Close() should be safe to call multiple times but paniced: %v", r)
+			}
+		}()
+		client.Close()
+	}()
+
 	msg, err := record.Encode()
 	assert.Check(t, err)
 	sender.Send(tstCtx, msg)
Repository: uber/makisu
Pull request #283 (2019-10-23 07:09:51)

trim quotes from copy from/to paths
closes https://github.com/uber/makisu/issues/276

preslavmihaylov: requesting a quick review @yiranwang52 
CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/uber/makisu?pullRequest=283) <br/>Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/uber/makisu?pullRequest=283) before we can accept your contribution.<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/uber/makisu?pullRequest=283) it.</sub>

Patch:
diff --git a/lib/builder/step/add_copy_step.go b/lib/builder/step/add_copy_step.go
index a53c94c..6157a02 100644
--- a/lib/builder/step/add_copy_step.go
+++ b/lib/builder/step/add_copy_step.go
@@ -64,6 +64,11 @@ func newAddCopyStep(
 	directive Directive, args, chown, fromStage string,
 	fromPaths []string, toPath string, commit bool) (*addCopyStep, error) {
 
+	toPath = strings.Trim(toPath, "\"'")
+	for i := range fromPaths {
+		fromPaths[i] = strings.Trim(fromPaths[i], "\"'")
+	}
+
 	if len(fromPaths) > 1 && !(strings.HasSuffix(toPath, "/") || toPath == "." || toPath == "..") {
 		return nil, fmt.Errorf("copying multiple source files, target must be a directory ending in \"/\"")
 	}


Test patch:
diff --git a/lib/builder/step/add_copy_step_test.go b/lib/builder/step/add_copy_step_test.go
index 8076ede..e151389 100644
--- a/lib/builder/step/add_copy_step_test.go
+++ b/lib/builder/step/add_copy_step_test.go
@@ -44,3 +44,13 @@ func TestContextDirs(t *testing.T) {
 	require.Equal("stage", stage)
 	require.Len(paths, 1)
 }
+
+func TestTrimmingPaths(t *testing.T) {
+	require := require.New(t)
+
+	ac, err := newAddCopyStep(Copy, "", "", "", []string{"\"/from/path\""}, "\"/to/path\"", false)
+	require.NoError(err)
+
+	require.Equal("/from/path", ac.fromPaths[0])
+	require.Equal("/to/path", ac.toPath)
+}
Repository: uber/makisu
Pull request #288 (2019-10-31 17:49:18)

Untar: Fixing symlink untarring in memfs


Patch:
diff --git a/lib/snapshot/mem_fs.go b/lib/snapshot/mem_fs.go
index 0bd23cd..994e7b1 100644
--- a/lib/snapshot/mem_fs.go
+++ b/lib/snapshot/mem_fs.go
@@ -659,9 +659,6 @@ func (fs *MemFS) untarDirectory(path string, header *tar.Header) error {
 // untarSymlink creates the symlink specified by header at path.
 func (fs *MemFS) untarSymlink(path string, header *tar.Header) error {
 	target := header.Linkname
-	if filepath.IsAbs(header.Linkname) {
-		target = filepath.Join(fs.tree.src, target)
-	}
 	if err := os.Symlink(target, path); err != nil {
 		return fmt.Errorf("create symlink %s => %s: %s", path, target, err)
 	}


Test patch:
diff --git a/lib/snapshot/mem_fs_test.go b/lib/snapshot/mem_fs_test.go
index b285ccd..cb0ce37 100644
--- a/lib/snapshot/mem_fs_test.go
+++ b/lib/snapshot/mem_fs_test.go
@@ -89,9 +89,9 @@ func TestUntarFromPath(t *testing.T) {
 	require.NoError(err)
 	require.False(fi.IsDir())
 
-	contents, err = ioutil.ReadFile(filepath.Join(tmpRoot, "mydir"))
+	target, err := os.Readlink(filepath.Join(tmpRoot, "mydir"))
 	require.NoError(err)
-	require.Equal([]byte("TARGET"), contents)
+	require.Equal("/target.txt", target)
 
 	require.Equal(7, fs.layers[len(fs.layers)-1].count())
Repository: uber/makisu
Pull request #293 (2019-12-05 06:12:52)

Revert "Untar: Fixing symlink untarring in memfs (#288)"
This reverts commit c28fc3a57c2ff71a3da9275e6a7c1bb728810e0c.

#288 caused a few new issues with symlinks, and i don't think it's the right fix for the extract problem.


Patch:
diff --git a/lib/snapshot/mem_fs.go b/lib/snapshot/mem_fs.go
index 994e7b1..0bd23cd 100644
--- a/lib/snapshot/mem_fs.go
+++ b/lib/snapshot/mem_fs.go
@@ -659,6 +659,9 @@ func (fs *MemFS) untarDirectory(path string, header *tar.Header) error {
 // untarSymlink creates the symlink specified by header at path.
 func (fs *MemFS) untarSymlink(path string, header *tar.Header) error {
 	target := header.Linkname
+	if filepath.IsAbs(header.Linkname) {
+		target = filepath.Join(fs.tree.src, target)
+	}
 	if err := os.Symlink(target, path); err != nil {
 		return fmt.Errorf("create symlink %s => %s: %s", path, target, err)
 	}


Test patch:
diff --git a/lib/snapshot/mem_fs_test.go b/lib/snapshot/mem_fs_test.go
index cb0ce37..b285ccd 100644
--- a/lib/snapshot/mem_fs_test.go
+++ b/lib/snapshot/mem_fs_test.go
@@ -89,9 +89,9 @@ func TestUntarFromPath(t *testing.T) {
 	require.NoError(err)
 	require.False(fi.IsDir())
 
-	target, err := os.Readlink(filepath.Join(tmpRoot, "mydir"))
+	contents, err = ioutil.ReadFile(filepath.Join(tmpRoot, "mydir"))
 	require.NoError(err)
-	require.Equal("/target.txt", target)
+	require.Equal([]byte("TARGET"), contents)
 
 	require.Equal(7, fs.layers[len(fs.layers)-1].count())