chore: Remove project template endpoints#109632
Conversation
We didn't ever finish off this feature and it has languished for a many months. Remove the endpoints and tests as a first step, next I'll remove the models.
|
|
||
| return project | ||
|
|
||
| @staticmethod | ||
| @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): |
There was a problem hiding this comment.
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.
| kwargs["teams"] = [self.team] | ||
| return Factories.create_project(**kwargs) | ||
|
|
||
| def create_project_template(self, **kwargs) -> ProjectTemplate: |
There was a problem hiding this comment.
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)
|
|
||
| return project | ||
|
|
||
| @staticmethod |
There was a problem hiding this comment.
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.
|
🚨 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| 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 |
There was a problem hiding this comment.
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.
Backend Test FailuresFailures on
|


We didn't ever finish off this feature and it has languished for a many months. With the OTLP taking a different route, I don't see us using ProjectTemplates any time soon.
Remove the endpoints and tests as a first step, next I'll remove the models.