Skip to content

Commit

Permalink
fix: Avoid printing huge log when a request fails
Browse files Browse the repository at this point in the history
fix #1286
  • Loading branch information
Rafiot committed Aug 21, 2024
1 parent f7ebf32 commit 3237a5e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pymisp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3985,7 +3985,10 @@ def _check_response(self, response: requests.Response, lenient_response_type: bo
"""Check if the response from the server is not an unexpected error"""
if response.status_code >= 500:
headers_without_auth = {h_name: h_value for h_name, h_value in response.request.headers.items() if h_value != self.key}
logger.critical(everything_broken.format(headers_without_auth, response.request.body, response.text))
if logger.level == logging.DEBUG:
logger.debug(everything_broken.format(headers_without_auth, response.request.body, response.text))
else:
logger.critical(everything_broken.format(headers_without_auth, response.request.body, f'{response.text[:1000]}... (enable debug mode for more details)'))
raise MISPServerError(f'Error code 500:\n{response.text}')

if 400 <= response.status_code < 500:
Expand Down

0 comments on commit 3237a5e

Please sign in to comment.