diff --git a/audit/internal/app/component_status_db.go b/audit/internal/app/component_status_db.go index 4aae112..689cc4f 100644 --- a/audit/internal/app/component_status_db.go +++ b/audit/internal/app/component_status_db.go @@ -223,8 +223,8 @@ func satStatusToDBStatus(overall string) string { } } -// ExtractArchivePath extracts a bare .tar.gz path from a string that may be -// "Archive written to /path/foo.tar.gz" or already a bare path. +// ExtractArchivePath extracts a bare path from a string that may be +// "Archive written to /path/to/run-dir" or already a bare path. func ExtractArchivePath(s string) string { return extractArchivePath(s) } @@ -247,11 +247,8 @@ func ReadSATOverallStatus(archivePath string) string { func extractArchivePath(s string) string { s = strings.TrimSpace(s) - if strings.HasSuffix(s, ".tar.gz") { - parts := strings.Fields(s) - if len(parts) > 0 { - return parts[len(parts)-1] - } + if rest, ok := strings.CutPrefix(s, "Archive written to "); ok { + return strings.TrimSpace(rest) } return s } diff --git a/audit/internal/app/component_status_db_test.go b/audit/internal/app/component_status_db_test.go new file mode 100644 index 0000000..d818bcc --- /dev/null +++ b/audit/internal/app/component_status_db_test.go @@ -0,0 +1,42 @@ +package app + +import ( + "os" + "path/filepath" + "testing" +) + +func TestExtractArchivePath(t *testing.T) { + cases := map[string]string{ + "/appdata/bee/export/bee-sat/gpu-nvidia-20260706-174722": "/appdata/bee/export/bee-sat/gpu-nvidia-20260706-174722", + "Archive written to /appdata/bee/export/bee-sat/gpu-nvidia-20260706-174722": "/appdata/bee/export/bee-sat/gpu-nvidia-20260706-174722", + "Archive written to /path/with spaces/foo.tar.gz": "/path/with spaces/foo.tar.gz", + " Archive written to /path/foo.tar.gz ": "/path/foo.tar.gz", + } + for in, want := range cases { + if got := ExtractArchivePath(in); got != want { + t.Errorf("ExtractArchivePath(%q) = %q, want %q", in, got, want) + } + } +} + +func TestReadSATOverallStatus_HandlesActionResultPrefix(t *testing.T) { + runDir := t.TempDir() + summary := "run_at_utc=2026-07-06T17:47:22Z\noverall_status=FAILED\n" + if err := os.WriteFile(filepath.Join(runDir, "summary.txt"), []byte(summary), 0644); err != nil { + t.Fatal(err) + } + + // Regression: RunNvidiaAcceptancePackWithOptions wraps the bare run dir as + // "Archive written to " before it reaches ReadSATOverallStatus. If the + // prefix isn't stripped, the summary.txt lookup silently fails and a FAILED + // sub-job never surfaces as a task failure. + wrapped := "Archive written to " + runDir + if got := ReadSATOverallStatus(ExtractArchivePath(wrapped)); got != "FAILED" { + t.Errorf("ReadSATOverallStatus(wrapped) = %q, want FAILED", got) + } + + if got := ReadSATOverallStatus(ExtractArchivePath(runDir)); got != "FAILED" { + t.Errorf("ReadSATOverallStatus(bare) = %q, want FAILED", got) + } +}