Skip to content

impr(detectors api): Add new endpoint with project in path for detector creation#110285

Open
Christinarlong wants to merge 4 commits intomasterfrom
crl/add-project-detector-endpoint
Open

impr(detectors api): Add new endpoint with project in path for detector creation#110285
Christinarlong wants to merge 4 commits intomasterfrom
crl/add-project-detector-endpoint

Conversation

@Christinarlong
Copy link
Contributor

@Christinarlong Christinarlong commented Mar 10, 2026

We want to support taking in the project id & slug for detector creation. We can't blanket change the current OrganizationDetectorIndex endpoint to be project qualified as the PUT, DELETE & GET endpoints take in many projects via query parameters. This PR introduces a new endpoint w/ project_id or slug in the path params for detector creation specific to a project.

  • Bulk operations will continue to use the previous OrganizationDetectorIndex endpoint.
  • The deprecation will be, New endpoint (this PR) -> Update calling code/frontend -> Delete old endpoint

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 10, 2026
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 10, 2026
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@Christinarlong Christinarlong marked this pull request as ready for review March 10, 2026 17:05
@Christinarlong Christinarlong requested a review from a team as a code owner March 10, 2026 17:05
Comment on lines +33 to +36
class OrganizationProjectDetectorPermission(ProjectPermission):
scope_map = {
"POST": ["project:write", "project:admin", "alerts:write"],
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scope map is based off of ProjectAlertRulePermission, since the old endpoint's map was org based.

| '/organizations/$organizationIdOrSlug/project-transaction-threshold-override/'
| '/organizations/$organizationIdOrSlug/projects-count/'
| '/organizations/$organizationIdOrSlug/projects/'
| '/organizations/$organizationIdOrSlug/projects/$projectIdOrSlug/detectors/'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did pre-commit do this 😭

404: RESPONSE_NOT_FOUND,
},
)
def post(self, request: Request, project: Project) -> Response:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic of this endpoint is all copied from OrganizationDetectorIndex's POST, minus the projectId validation parts since the base ProjectEndpoint will handle that validation for us.

@Christinarlong Christinarlong requested review from a team and ceorourke March 10, 2026 17:05
@ceorourke
Copy link
Member

The thread about the direction of this was long but I thought we were just going to have the existing endpoint accept a projectSlug param? If we really want to go in this direction I'll need to loop in Nick as our Terraform updates have already been completed and this would require another change on that side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants