Skip to content

Conversation

jasonyuezhang
Copy link
Owner

This is an expected state, so IMO it should be a successful response with an empty list instead of a 404. This makes things simpler on the UI side.


Copied from getsentry#101046
Original PR: getsentry#101046

Copy link

Return Empty List When No Group Linked in Open Periods Endpoint

This PR updates the organization_open_periods.py API endpoint to return an empty list (HTTP 200) instead of a 404 error when there is no group linked to a detector. Corresponding test coverage in test_organization_open_periods.py is modified to expect and assert the new successful empty response rather than an error. The change aligns the API response with an expected, non-error state, thereby simplifying UI handling on the client side.

Key Changes

• In src/sentry/workflow_engine/endpoints/organization_open_periods.py, replaced Response with 404 status and error message for missing groups with a call to self.paginate on an empty queryset, returning an empty list and HTTP 200.
• Updated tests/sentry/workflow_engine/endpoints/test_organization_open_periods.py to assert empty list responses when no group is linked to a detector, removing previous checks for 404 and error detail.
• Removed unused import of status from rest_framework in both the endpoint and test files.

Affected Areas

src/sentry/workflow_engine/endpoints/organization_open_periods.py
tests/sentry/workflow_engine/endpoints/test_organization_open_periods.py

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

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