From 5abc586749d725e944d2c12da754bc3db28f7a50 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Mon, 10 Jul 2023 12:11:29 -0700 Subject: [PATCH] merging receive: Web: handle ValueError raised by protocol.receive for #529 --- tests/test_web.py | 7 ++++--- web.py | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_web.py b/tests/test_web.py index 35c7ef3..3b8c9f7 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -601,8 +601,9 @@ class WebTest(TestCase): mock_get.return_value = requests_response(""" -

no one to send to!

+

no one to send to!

+ """, url='https://user.com/post', content_type=CONTENT_TYPE_HTML) got = self.client.post('/_ah/queue/webmention', data={ @@ -1221,7 +1222,7 @@ class WebTest(TestCase): 'source': 'https://user.com/follow', 'target': 'https://fed.brid.gy/', }) - self.assertEqual(400, got.status_code) + self.assertEqual(304, got.status_code) mock_post.assert_not_called() def test_follow_fragment(self, mock_get, mock_post): @@ -1997,7 +1998,7 @@ class WebUtilTest(TestCase): - + Ms. ☕ Baz diff --git a/web.py b/web.py index 9f60fca..edc7254 100644 --- a/web.py +++ b/web.py @@ -564,4 +564,8 @@ def webmention_task(): 'object': actor_as1, }) - return Web.receive(obj) + try: + return Web.receive(obj) + except ValueError as e: + logger.warning(e, exc_info=True) + error(e, status=304)