From f9b2fd75d10d19cc2f26cac5e00aecaf1a9900fa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 03:37:27 +0000 Subject: [PATCH 1/2] Initial plan From d90d4deccad794c2427f16d3f9faac02e8010d10 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 03:50:58 +0000 Subject: [PATCH 2/2] fix: use absolute paths for downloaded_files in audit report The extractDownloadedFiles function was converting absolute paths to relative paths using filepath.Rel(cwd, fullPath), producing confusing paths like ../../../../../tmp/gh-aw/... when the cwd is deep in the repo directory. Replace the relative path calculation with filepath.Abs to always return absolute paths that are directly usable by callers. Fixes # Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/audit_report.go | 20 ++++++-------------- pkg/cli/audit_report_helpers_test.go | 11 +++++++++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/cli/audit_report.go b/pkg/cli/audit_report.go index 9c4d7bf223e..b591e0822b5 100644 --- a/pkg/cli/audit_report.go +++ b/pkg/cli/audit_report.go @@ -339,13 +339,6 @@ func extractDownloadedFiles(logsPath string) []FileInfo { return files } - // Get current working directory to calculate relative paths - cwd, err := os.Getwd() - if err != nil { - auditReportLog.Printf("Failed to get current directory: %v", err) - cwd = "" - } - for _, entry := range entries { // Skip directories if entry.IsDir() { @@ -355,16 +348,15 @@ func extractDownloadedFiles(logsPath string) []FileInfo { name := entry.Name() fullPath := filepath.Join(logsPath, name) - // Calculate relative path from workspace root (current working directory) - relativePath := fullPath - if cwd != "" { - if relPath, err := filepath.Rel(cwd, fullPath); err == nil { - relativePath = relPath - } + // Use absolute path so callers get a directly usable path + absPath, err := filepath.Abs(fullPath) + if err != nil { + auditReportLog.Printf("Failed to resolve absolute path for %s: %v", fullPath, err) + absPath = fullPath } fileInfo := FileInfo{ - Path: relativePath, + Path: absPath, Description: describeFile(name), } diff --git a/pkg/cli/audit_report_helpers_test.go b/pkg/cli/audit_report_helpers_test.go index 49e8f9c5e7a..6e93c090f6b 100644 --- a/pkg/cli/audit_report_helpers_test.go +++ b/pkg/cli/audit_report_helpers_test.go @@ -177,10 +177,17 @@ func TestDownloadedFilesInAuditData(t *testing.T) { t.Errorf("Expected %d files, got %d", expectedCount, len(files)) } + // Verify all paths are absolute + for _, file := range files { + if !filepath.IsAbs(file.Path) { + t.Errorf("Expected absolute path, got relative path: %s", file.Path) + } + } + // Verify specific files have correct attributes fileMap := make(map[string]FileInfo) for _, file := range files { - // Use basename for lookup since paths are now relative to workspace root + // Use basename for lookup since we only need to find files by name basename := filepath.Base(file.Path) fileMap[basename] = file } @@ -323,7 +330,7 @@ func TestAuditReportFileListingIntegration(t *testing.T) { // Build a map for easy lookup fileMap := make(map[string]FileInfo) for _, f := range files { - // Use basename for lookup since paths are now relative to workspace root + // Use basename for lookup since we only need to find files by name basename := filepath.Base(f.Path) fileMap[basename] = f }