Ignore it when flaky instances provide a HTML instead of JSON response

This commit is contained in:
freamon 2024-08-21 15:27:47 +00:00
parent 123536b006
commit 12f488bfc1

View file

@ -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'