From aff5807e956a4d7278ae172def2db863dc3a47d1 Mon Sep 17 00:00:00 2001 From: Matthias Klumpp Date: Sat, 2 Nov 2024 06:39:17 +0100 Subject: [PATCH] Only emit obfuscated traceback for unexpected errors --- src/laniakea/archive/pkgimport.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/laniakea/archive/pkgimport.py b/src/laniakea/archive/pkgimport.py index 39ce8cfe..2fba3544 100644 --- a/src/laniakea/archive/pkgimport.py +++ b/src/laniakea/archive/pkgimport.py @@ -1337,8 +1337,15 @@ def _import_trusted_changes( os.path.join(spkg_queue_dir, '{}_{}.changes'.format(spkg.name, split_epoch(spkg.version)[1])), ) except Exception as e: - tb_s = format_encrypted_traceback(e) - raise UploadError('Failed to import source package: {}\nDiagnostic Code: {}'.format(str(e), tb_s)) + message = 'Failed to import source package: {}'.format(str(e)) + if not isinstance( + e, (ArchiveImportError, ArchiveImportNewError, ArchivePackageExistsError, HashVerifyError) + ): + # we only emit an encrypted traceback in case of unexpected/uncommon errors + tb_s = format_encrypted_traceback(e) + message += '\nDiagnostic Code: {}'.format(tb_s) + + raise UploadError(message) # import binary packages for file in files.values(): @@ -1348,8 +1355,15 @@ def _import_trusted_changes( try: pi.import_binary(os.path.join(changes.directory, file.fname), file.component) except Exception as e: - tb_s = format_encrypted_traceback(e) - raise UploadError('Failed to import binary package: {}\nDiagnostic Code: {}'.format(str(e), tb_s)) + message = 'Failed to import binary package: {}'.format(str(e)) + if not isinstance( + e, (ArchiveImportError, ArchiveImportNewError, ArchivePackageExistsError, HashVerifyError) + ): + # we only emit an encrypted traceback in case of unexpected/uncommon errors + tb_s = format_encrypted_traceback(e) + message += '\nDiagnostic Code: {}'.format(tb_s) + + raise UploadError(message) # looks like the package was accepted - spread the news! ev_data = build_event_data_for_accepted_upload(rss, spkg, changes, is_new, uploader)