Skip to content

Commit

Permalink
fix(crons): Fix KeyError in capture_checkin if SDK is not initialized (
Browse files Browse the repository at this point in the history
…#2073)

When Sentry SDK was not initialized, any calls to capture_checkin()
raised a KeyError. This made all calls to functions decorated with
@sentry_sdk.monitor() fail, because capture_checkin() is always called
within the decorator.

Co-authored-by: Jan Smitka <jan.smitka@lynt.cz>
  • Loading branch information
antonpirker and jsmitka authored May 4, 2023
1 parent 92e24b4 commit a0f11e5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_crons.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,15 @@ def test_monitor_config(sentry_init, capture_envelopes):

assert check_in["monitor_slug"] == "abc123"
assert "monitor_config" not in check_in


def test_capture_checkin_sdk_not_initialized():
# Tests that the capture_checkin does not raise an error when Sentry SDK is not initialized.
# sentry_init() is intentionally omitted.
check_in_id = capture_checkin(
monitor_slug="abc123",
check_in_id="112233",
status=None,
duration=None,
)
assert check_in_id == "112233"

0 comments on commit a0f11e5

Please sign in to comment.