From 6f83958bb6c703e5ad6b1c989cf155eab3c95102 Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Wed, 27 Apr 2022 12:40:51 +0200 Subject: [PATCH] [Fix] Ignore invalid messages in messages job Fixed an issue uncovered by the fix logging all errors from the message processing job. The message check function throws an InvalidMessageError exception if the message is invalid. This fix adds a try/except block to catch the exception and mark the message as failed. --- src/aleph/chains/common.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/aleph/chains/common.py b/src/aleph/chains/common.py index 03cb413e9..cde886f71 100644 --- a/src/aleph/chains/common.py +++ b/src/aleph/chains/common.py @@ -8,7 +8,9 @@ from aleph.exceptions import ( AlephStorageException, InvalidContent, - ContentCurrentlyUnavailable, UnknownHashError, + ContentCurrentlyUnavailable, + UnknownHashError, + InvalidMessageError, ) from aleph.handlers.forget import handle_forget_message from aleph.handlers.storage import handle_new_storage @@ -136,9 +138,12 @@ async def incoming( if check_message: if existing is None or (existing["signature"] != message["signature"]): # check/sanitize the message if needed - message = await check_message_fn( - message, from_chain=(chain_name is not None) - ) + try: + message = await check_message_fn( + message, from_chain=(chain_name is not None) + ) + except InvalidMessageError: + return IncomingStatus.FAILED_PERMANENTLY, [] if message is None: return IncomingStatus.MESSAGE_HANDLED, []