Skip to content

Conversation

jasonyuezhang
Copy link
Owner

Move uptime subscription limit checking from exception handling in
create() to validator validation method. This ensures limits are checked
during validation phase when creating new uptime monitors, providing
consistent error responses and cleaner code.

Follows the same pattern as cron monitors for consistency.\n\n---\nCopied from getsentry#100904\nOriginal PR: getsentry#100904

Copy link

propel-test-bot bot commented Oct 3, 2025

Refactor: Move Uptime Subscription Limit Check Into Validator

This pull request refactors where organization uptime subscription limits are enforced. The check to prevent exceeding the maximum number of manual uptime monitors per organization is moved from exception handling in the create_uptime_detector function to the validation phase in the UptimeMonitorValidator. This adjustment ensures that such limits are checked earlier (during validation), yielding more consistent error responses and aligning the uptime monitor behavior with cron monitor validation patterns. Supporting utility logic is extracted into a new function, check_uptime_subscription_limit, in src/sentry/uptime/subscriptions/subscriptions.py.

Key Changes

• Added check_uptime_subscription_limit function to src/sentry/uptime/subscriptions/subscriptions.py for enforcing org-level manual monitor limits.
• Moved limit checking logic from the create_uptime_detector implementation into the validate method of UptimeMonitorValidator in src/sentry/uptime/endpoints/validators.py.
• Removed redundant checks for manual subscription limits from the create_uptime_detector function.
• Updated logic to ensure subscription limit exceptions now trigger serializers.ValidationError during validation, not in exception handling post-create.

Affected Areas

src/sentry/uptime/endpoints/validators.py
src/sentry/uptime/subscriptions/subscriptions.py

This summary was automatically generated by @propel-code-bot

Move uptime subscription limit checking from exception handling in
create() to validator validation method. This ensures limits are checked
during validation phase when creating new uptime monitors, providing
consistent error responses and cleaner code.

Follows the same pattern as cron monitors for consistency.
@jasonyuezhang jasonyuezhang force-pushed the evanpurkhiser/ref-uptime-move-subscription-limit-check-to-validator branch from 56ed33e to 09c45a6 Compare October 3, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants