Skip to content

Commit

Permalink
sosreport: Add fallback error message
Browse files Browse the repository at this point in the history
If `sos report` fails, we can get an empty message in `error`. That will
lead to not showing the error in the dialog at all (as it's falsy), even
if errorDetail was set. Fix that by adding a generic fallback title.

Also log the full error for easier debugging.
  • Loading branch information
martinpitt committed Jul 18, 2023
1 parent 86510f8 commit ece5d7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/sosreport/sosreport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ function sosCreate(args, setProgress, setError, setErrorDetail) {
});

task.catch(error => {
setError(error.toString());
console.error(JSON.stringify(error));
setError(error.toString() || _("sos report failed"));
setErrorDetail(output);
});

Expand Down
12 changes: 12 additions & 0 deletions test/verify/check-sosreport
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ only-plugins=release,date,host,cgroups,networking
b.click("#sos-remove-dialog button:contains(Delete)")
testlib.wait(lambda: m.execute(f"! test -f /var/tmp/{base_report_gpg} && echo yes"))

# error reporting
self.write_file("/usr/local/bin/sos", """#!/bin/sh
echo "EssOhEss is kaputt" >&2
exit 1""", perm="755")
b.click("button:contains('Run report')")
b.wait_visible("#sos-dialog")
b.click("#sos-dialog button:contains(Run report)")
b.wait_in_text("#sos-dialog .pf-v5-c-alert", "sos report failed")
b.wait_in_text("#sos-dialog .pf-v5-c-alert", "EssOhEss is kaputt")
b.click("#sos-dialog button:contains(Cancel)")
b.wait_not_present("#sos-dialog")

self.allow_journal_messages('.*comm="sosreport".*')

def testWithUrlRoot(self):
Expand Down

0 comments on commit ece5d7d

Please sign in to comment.