-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(crons): Add stronger typing to error responses #70709
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/sentry/monitors/endpoints/project_processing_errors_details.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from __future__ import annotations | ||
|
||
from uuid import UUID | ||
|
||
from drf_spectacular.utils import extend_schema | ||
from rest_framework.exceptions import ValidationError | ||
from rest_framework.permissions import BasePermission | ||
from rest_framework.request import Request | ||
from rest_framework.response import Response | ||
|
||
from sentry.api.api_owners import ApiOwner | ||
from sentry.api.api_publish_status import ApiPublishStatus | ||
from sentry.api.base import region_silo_endpoint | ||
from sentry.api.bases import ProjectEndpoint | ||
from sentry.apidocs.constants import ( | ||
RESPONSE_FORBIDDEN, | ||
RESPONSE_NO_CONTENT, | ||
RESPONSE_NOT_FOUND, | ||
RESPONSE_UNAUTHORIZED, | ||
) | ||
from sentry.apidocs.parameters import GlobalParams, MonitorParams | ||
from sentry.models.project import Project | ||
from sentry.monitors.endpoints.base import ProjectMonitorPermission | ||
from sentry.monitors.processing_errors import CheckinProcessErrorsManager, InvalidProjectError | ||
|
||
|
||
@region_silo_endpoint | ||
@extend_schema(tags=["Crons"]) | ||
class ProjectProcessingErrorsDetailsEndpoint(ProjectEndpoint): | ||
permission_classes: tuple[type[BasePermission], ...] = (ProjectMonitorPermission,) | ||
|
||
publish_status = { | ||
"DELETE": ApiPublishStatus.PRIVATE, | ||
} | ||
owner = ApiOwner.CRONS | ||
|
||
@extend_schema( | ||
operation_id="Delete a processing error for a Monitor", | ||
parameters=[ | ||
GlobalParams.ORG_SLUG, | ||
GlobalParams.PROJECT_ID_OR_SLUG, | ||
MonitorParams.PROCESSING_ERROR_ID, | ||
], | ||
responses={ | ||
204: RESPONSE_NO_CONTENT, | ||
401: RESPONSE_UNAUTHORIZED, | ||
403: RESPONSE_FORBIDDEN, | ||
404: RESPONSE_NOT_FOUND, | ||
}, | ||
) | ||
def delete(self, request: Request, project: Project, uuid: str) -> Response: | ||
try: | ||
parsed_uuid = UUID(uuid) | ||
except ValueError: | ||
raise ValidationError("Invalid UUID") | ||
try: | ||
CheckinProcessErrorsManager().delete(project, parsed_uuid) | ||
except InvalidProjectError: | ||
raise ValidationError("Invalid uuid for project") | ||
return self.respond(status=204) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up @wedamija looks like sometimes your editor is wanting to do parent relative imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just copies other patterns it sees, so since it sees relative imports it does dumb stuff like this