Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
97 changes: 0 additions & 97 deletions src/sentry/api/endpoints/project_template_detail.py

This file was deleted.

87 changes: 0 additions & 87 deletions src/sentry/api/serializers/models/project_template.py

This file was deleted.

12 changes: 0 additions & 12 deletions src/sentry/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
from sentry.api.endpoints.project_overview import ProjectOverviewEndpoint
from sentry.api.endpoints.project_stacktrace_coverage import ProjectStacktraceCoverageEndpoint
from sentry.api.endpoints.project_statistical_detectors import ProjectStatisticalDetectors
from sentry.api.endpoints.project_template_detail import OrganizationProjectTemplateDetailEndpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

Orphaned endpoint file left with broken imports

Medium Severity

The PR deletes project_template_detail.py, the serializer project_template.py, and removes both URL registrations from urls.py, but leaves project_templates_index.py in the codebase. That orphaned file imports from the now-deleted sentry.api.serializers.models.project_template, so any attempt to import it will fail. Since the PR's stated goal is to remove the project template endpoints, this file appears to have been missed.

Fix in Cursor Fix in Web

from sentry.api.endpoints.project_templates_index import OrganizationProjectTemplatesIndexEndpoint
from sentry.api.endpoints.project_web_vitals_detection import ProjectWebVitalsDetectionEndpoint
from sentry.api.endpoints.release_thresholds.release_threshold import ReleaseThresholdEndpoint
from sentry.api.endpoints.release_thresholds.release_threshold_details import (
Expand Down Expand Up @@ -1716,16 +1714,6 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]:
OrganizationEventsAnomaliesEndpoint.as_view(),
name="sentry-api-0-organization-events-anomalies",
),
re_path(
r"^(?P<organization_id_or_slug>[^/]+)/project-templates/$",
OrganizationProjectTemplatesIndexEndpoint.as_view(),
name="sentry-api-0-organization-project-templates",
),
re_path(
r"^(?P<organization_id_or_slug>[^/]+)/project-templates/(?P<template_id>[^/]+)/$",
OrganizationProjectTemplateDetailEndpoint.as_view(),
name="sentry-api-0-organization-project-template-detail",
),
re_path(
r"^(?P<organization_id_or_slug>[^/]+)/traces/$",
OrganizationTracesEndpoint.as_view(),
Expand Down
12 changes: 0 additions & 12 deletions src/sentry/testutils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
from sentry.models.project import Project
from sentry.models.projectbookmark import ProjectBookmark
from sentry.models.projectcodeowners import ProjectCodeOwners
from sentry.models.projecttemplate import ProjectTemplate
from sentry.models.pullrequest import PullRequestCommit
from sentry.models.release import Release, ReleaseStatus
from sentry.models.releasecommit import ReleaseCommit
Expand Down Expand Up @@ -588,17 +587,6 @@ def create_project(

return project

@staticmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

Orphaned endpoint file imports from deleted serializer module

Medium Severity

src/sentry/api/endpoints/project_templates_index.py still exists and imports ProjectTemplateSerializer and ProjectTemplateWriteSerializer from the now-deleted src/sentry/api/serializers/models/project_template.py. The URL route was removed and nothing imports this file anymore, but it's orphaned dead code with a broken import that will error if anyone tries to use or import it.

Fix in Cursor Fix in Web

@assume_test_silo_mode(SiloMode.REGION)
def create_project_template(project=None, organization=None, **kwargs) -> ProjectTemplate:
if not kwargs.get("name"):
kwargs["name"] = petname.generate(2, " ", letters=10).title()

with transaction.atomic(router.db_for_write(Project)):
project_template = ProjectTemplate.objects.create(organization=organization, **kwargs)

return project_template

@staticmethod
@assume_test_silo_mode(SiloMode.CONTROL)
def create_data_access_grant(**kwargs):
Comment on lines 587 to 592
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: The ProjectOptionsTests test class calls the create_project_template() method in its setUp() function, but this method has been removed from the test utility classes, which will cause an AttributeError.
Severity: CRITICAL

Suggested Fix

The ProjectOptionsTests class and its usage of create_project_template() should be removed or updated. Since the functionality related to project templates is being removed, the associated tests are likely no longer necessary and should be deleted.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/testutils/factories.py#L587-L592

Potential issue: The pull request removes the test helper method
`create_project_template()` from `src/sentry/testutils/factories.py` and
`src/sentry/testutils/fixtures.py`. However, the test class `ProjectOptionsTests` in
`tests/sentry/models/test_project.py` still invokes this method within its `setUp()`
function. Because the test class inherits from `TestCase`, which uses the `Fixtures`
class, the call to the now-nonexistent `self.create_project_template()` will raise an
`AttributeError`. This will cause all tests within the `ProjectOptionsTests` suite to
fail during setup, preventing them from running.

Did we get this right? 👍 / 👎 to inform future reviews.

Expand Down
4 changes: 0 additions & 4 deletions src/sentry/testutils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from sentry.models.organizationmember import OrganizationMember
from sentry.models.organizationmemberteam import OrganizationMemberTeam
from sentry.models.project import Project
from sentry.models.projecttemplate import ProjectTemplate
from sentry.models.rule import Rule
from sentry.models.team import Team
from sentry.monitors.models import (
Expand Down Expand Up @@ -216,9 +215,6 @@ def create_project(self, **kwargs) -> Project:
kwargs["teams"] = [self.team]
return Factories.create_project(**kwargs)

def create_project_template(self, **kwargs) -> ProjectTemplate:
Copy link
Contributor

Choose a reason for hiding this comment

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

Removed factory method still used in existing test

High Severity

The create_project_template helper was removed from both Factories and Fixtures, but tests/sentry/models/test_project.py line 654 still calls self.create_project_template() in the ProjectOptionsTests.setUp() method. This will cause an AttributeError at test runtime, breaking the entire ProjectOptionsTests test class (including test_get_option, test_get_template_option, test_get_option__override_template, and test_get_option__without_template).

Additional Locations (1)

Fix in Cursor Fix in Web

return Factories.create_project_template(**kwargs)

def create_project_bookmark(self, project=None, *args, **kwargs):
if project is None:
project = self.project
Expand Down
Loading
Loading