outgoing_webhook: Ignore the exception on failure if the stream is gone.

In the outgoing webhook handler, there is potentially several seconds
of trying between when a message triggering an outgoing webhook
arrives, and when it fails.  In the meantime, the stream the
triggering message was on may have been deleted, causing the
"Failure!" message to have no valid stream to be sent to.

Rather than raise an exception in the outgoing webhook worker, ignore
the exception and move on.
This commit is contained in:
Alex Vandiver
2022-11-03 10:35:07 -04:00
committed by Tim Abbott
parent eb7a2f2c38
commit d8ebbedbbb
2 changed files with 43 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ from requests import Response
from version import ZULIP_VERSION
from zerver.actions.message_send import check_send_message
from zerver.lib.exceptions import JsonableError
from zerver.lib.exceptions import JsonableError, StreamDoesNotExistError
from zerver.lib.message import MessageDict
from zerver.lib.outgoing_http import OutgoingSession
from zerver.lib.queue import retry_event
@@ -232,7 +232,12 @@ def fail_with_message(event: Dict[str, Any], failure_message: str) -> None:
message_info = event["message"]
content = "Failure! " + failure_message
response_data = dict(content=content)
send_response_message(bot_id=bot_id, message_info=message_info, response_data=response_data)
try:
send_response_message(bot_id=bot_id, message_info=message_info, response_data=response_data)
except StreamDoesNotExistError:
# If the stream has vanished while we were failing, there's no
# reasonable place to report the error.
pass
def get_message_url(event: Dict[str, Any]) -> str: