From 12f488bfc154f2dc1ffd2d1c8c3da1cb00ef7da4 Mon Sep 17 00:00:00 2001 From: freamon Date: Wed, 21 Aug 2024 15:27:47 +0000 Subject: [PATCH] Ignore it when flaky instances provide a HTML instead of JSON response --- app/activitypub/signature.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/activitypub/signature.py b/app/activitypub/signature.py index cb10c23e..8e16c558 100644 --- a/app/activitypub/signature.py +++ b/app/activitypub/signature.py @@ -103,9 +103,12 @@ def post_request(uri: str, body: dict | None, private_key: str, key_id: str, con result = HttpSignature.signed_request(uri, body, private_key, key_id, content_type, method, timeout) if result.status_code != 200 and result.status_code != 202 and result.status_code != 204: log.result = 'failure' - log.exception_message += f' Response status code was {result.status_code}' + log.exception_message = f'{result.status_code}: {result.text:.100}' + ' - ' current_app.logger.error(f'Response code for post attempt to {uri} was ' + str(result.status_code) + ' ' + result.text) + if 'DOCTYPE html' in result.text: + log.result = 'ignored' + log.exception_message = f'{result.status_code}: HTML instead of JSON response - ' log.exception_message += uri if result.status_code == 202: log.exception_message += ' 202'