Blob Blame History Raw
From 61155974a597e49bbc2b33ba2dc1e3b70162d99e Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Tue, 11 Apr 2023 10:15:16 -0700
Subject: [PATCH] exception: only attach existent and non-empty files
 (#2185827)

libreport barfs (in a non-fatal but scary way) if a file we try
to attach does not exist or is empty. Let's make sure all the
files exist and aren't empty before we try to attach them. In a
current F38+ live install, for instance, both packaging.log and
dnf.librepo.log are usually empty.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
 pyanaconda/exception.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index d507cafcc2..3c39dff0f2 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -138,6 +138,10 @@ class AnacondaExceptionHandler(ExceptionHandler):
         """
 
         log.debug("running handleException")
+        # don't try and attach empty or non-existent files (#2185827)
+        self.conf.fileList = [
+            fn for fn in self.conf.fileList if os.path.exists(fn) and os.path.getsize(fn) > 0
+        ]
         exception_lines = traceback.format_exception(*dump_info.exc_info)
         log.critical("\n".join(exception_lines))
 
-- 
2.40.0