backups: Fix robust handling of known errors

During functional tests, it was noticed that getattr() failed at the following
line. The original intent of the code is to ensure that there are no failures
when 'stdout'/'stderr' attribute are not present or when they return None.

    stdout = (getattr(err, 'stdout') or b'').decode()

Tests:

- Make the UI raise incorrect password error. Notice that the error is shown
properly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2025-09-24 13:03:38 -07:00 committed by Veiko Aasa
parent daca4d1d9c
commit 647e72516c
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -118,8 +118,8 @@ def reraise_known_errors(privileged_func):
def _reraise_known_errors(err):
"""Look whether the caught error is known and reraise it accordingly"""
stdout = (getattr(err, 'stdout') or b'').decode()
stderr = (getattr(err, 'stderr') or b'').decode()
stdout = (getattr(err, 'stdout', b'') or b'').decode()
stderr = (getattr(err, 'stderr', b'') or b'').decode()
caught_error = str((err, err.args, stdout, stderr))
for known_error in KNOWN_ERRORS:
for error in known_error['errors']: