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

fix(crons): Fix KeyError in capture_checkin if SDK is not initialized #1982

Closed
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions sentry_sdk/crons.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def _create_checkin_event(
"check_in_id": check_in_id,
"status": status,
"duration": duration,
"environment": options["environment"],
"release": options["release"],
"environment": options.get("environment"),
"release": options.get("release"),
}

return checkin
Expand Down
12 changes: 12 additions & 0 deletions tests/test_crons.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,15 @@ def test_capture_checkin_new_id(sentry_init):
)

assert check_in_id == "a8098c1af86e11dabd1a00112444be1e"


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"