From 15ac16121bfa72f1e8622629e9bae846bcea1ede Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 30 Dec 2025 08:10:15 +0000 Subject: [PATCH] Fix unhandled error in test cleanup (Alert #392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added error handling for os.RemoveAll(tempDir) in t.Cleanup() function to prevent gosec G104 warning. Now logs warning if cleanup fails instead of silently ignoring the error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- pkg/testutil/tempdir.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/testutil/tempdir.go b/pkg/testutil/tempdir.go index 9cea03d058..0962e621e0 100644 --- a/pkg/testutil/tempdir.go +++ b/pkg/testutil/tempdir.go @@ -60,7 +60,9 @@ func TempDir(t *testing.T, pattern string) string { // Register cleanup to remove the directory after test completes t.Cleanup(func() { - os.RemoveAll(tempDir) + if err := os.RemoveAll(tempDir); err != nil { + t.Logf("Warning: failed to clean up temporary directory %s: %v", tempDir, err) + } }) return tempDir