Skip to content

Commit a0f11e5

Browse files
antonpirkerjsmitka
andauthored
fix(crons): Fix KeyError in capture_checkin if SDK is not initialized (#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 <[email protected]>
1 parent 92e24b4 commit a0f11e5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_crons.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,15 @@ def test_monitor_config(sentry_init, capture_envelopes):
133133

134134
assert check_in["monitor_slug"] == "abc123"
135135
assert "monitor_config" not in check_in
136+
137+
138+
def test_capture_checkin_sdk_not_initialized():
139+
# Tests that the capture_checkin does not raise an error when Sentry SDK is not initialized.
140+
# sentry_init() is intentionally omitted.
141+
check_in_id = capture_checkin(
142+
monitor_slug="abc123",
143+
check_in_id="112233",
144+
status=None,
145+
duration=None,
146+
)
147+
assert check_in_id == "112233"

0 commit comments

Comments
 (0)