Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax checks on response status code #389

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions bugsnag/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def deliver_sessions(self, config, payload: Any, options=None):
options = {}

options['endpoint'] = config.session_endpoint
options['success'] = 202

self.deliver(config, payload, options)

Expand Down Expand Up @@ -151,10 +150,14 @@ def request():
status = resp.getcode()

if 'success' in options:
success = options['success']
# if an expected status code has been given then it must match
# exactly with the actual status code
success = status == options['success']
else:
success = 200
if status != success:
# warn if we don't get a 2xx status code by default
success = status >= 200 and status < 300

if not success:
config.logger.warning(
'Delivery to %s failed, status %d' % (uri, status)
)
Expand Down Expand Up @@ -184,12 +187,16 @@ def request():

response = requests.post(uri, **req_options)
status = response.status_code

if 'success' in options:
success = options['success']
# if an expected status code has been given then it must match
# exactly with the actual status code
success = status == options['success']
else:
success = requests.codes.ok
# warn if we don't get a 2xx status code by default
success = status >= 200 and status < 300

if status != success:
if not success:
config.logger.warning(
'Delivery to %s failed, status %d' % (uri, status)
)
Expand Down
Loading