Browse Source

ref(processing-issues): Remove /processingissues/fix API endpoint and corresponding ProjectProcessingIssuesFixEndpoint (#46496)

This feature has been broken for 5 years now due to incorrectly used
sentry-cli command (`--uuid` instead of `--id` flag which was changed in
https://github.com/getsentry/sentry-cli/commit/e8965f8c7d32c67af22b4a5bb267911a45371ee3).

We will remove it from the UI first, and corresponding API removal will
follow.

UI change: https://github.com/getsentry/sentry/pull/46495

NOTE: We should wait for a few weeks before merging this. Set myself a
reminder to do so.
Kamil Ogórek 1 year ago
parent
commit
99543d69ff

+ 1 - 49
src/sentry/api/endpoints/project_processingissues.py

@@ -5,10 +5,8 @@ from sentry.api.base import region_silo_endpoint
 from sentry.api.bases.project import ProjectEndpoint
 from sentry.api.bases.project import ProjectEndpoint
 from sentry.api.helpers.processing_issues import get_processing_issues
 from sentry.api.helpers.processing_issues import get_processing_issues
 from sentry.api.serializers import serialize
 from sentry.api.serializers import serialize
-from sentry.models import ApiToken, ProcessingIssue
+from sentry.models import ProcessingIssue
 from sentry.reprocessing import trigger_reprocessing
 from sentry.reprocessing import trigger_reprocessing
-from sentry.utils.http import absolute_uri
-from sentry.web.helpers import render_to_response
 
 
 
 
 @region_silo_endpoint
 @region_silo_endpoint
@@ -21,52 +19,6 @@ class ProjectProcessingIssuesDiscardEndpoint(ProjectEndpoint):
         return Response(status=200)
         return Response(status=200)
 
 
 
 
-@region_silo_endpoint
-class ProjectProcessingIssuesFixEndpoint(ProjectEndpoint):
-    def get(self, request: Request, project) -> Response:
-        token = None
-
-        if request.user_from_signed_request and request.user.is_authenticated:
-            tokens = [
-                x
-                for x in ApiToken.objects.filter(user_id=request.user.id).all()
-                if "project:releases" in x.get_scopes()
-            ]
-            if not tokens:
-                token = ApiToken.objects.create(
-                    user_id=request.user.id,
-                    scope_list=["project:releases"],
-                    refresh_token=None,
-                    expires_at=None,
-                )
-            else:
-                token = tokens[0]
-
-        resp = render_to_response(
-            "sentry/reprocessing-script.sh",
-            {
-                "issues": [
-                    {
-                        "uuid": issue.data.get("image_uuid"),
-                        "arch": issue.data.get("image_arch"),
-                        "name": (issue.data.get("image_path") or "").split("/")[-1],
-                    }
-                    for issue in ProcessingIssue.objects.filter(project=project)
-                ],
-                "project": project,
-                "token": token,
-                "server_url": absolute_uri("/"),
-            },
-        )
-        resp["Content-Type"] = "text/plain"
-        return resp
-
-    def permission_denied(self, request: Request, **kwargs):
-        resp = render_to_response("sentry/reprocessing-script.sh", {"token": None})
-        resp["Content-Type"] = "text/plain"
-        return resp
-
-
 @region_silo_endpoint
 @region_silo_endpoint
 class ProjectProcessingIssuesEndpoint(ProjectEndpoint):
 class ProjectProcessingIssuesEndpoint(ProjectEndpoint):
     def get(self, request: Request, project) -> Response:
     def get(self, request: Request, project) -> Response:

+ 1 - 16
src/sentry/api/helpers/processing_issues.py

@@ -4,7 +4,6 @@ from django.db.models import Count, Max
 
 
 from sentry.api.serializers import serialize
 from sentry.api.serializers import serialize
 from sentry.models import ProcessingIssue, ReprocessingReport
 from sentry.models import ProcessingIssue, ReprocessingReport
-from sentry.utils.linksign import generate_signed_link
 
 
 
 
 def get_processing_issues(user, projects, include_detailed_issues=False):
 def get_processing_issues(user, projects, include_detailed_issues=False):
@@ -22,8 +21,6 @@ def get_processing_issues(user, projects, include_detailed_issues=False):
         - 'hasMoreResolveableIssues': Whether there are any Raw Events that
         - 'hasMoreResolveableIssues': Whether there are any Raw Events that
         have no remaining issues and can be resolved automatically
         have no remaining issues and can be resolved automatically
         'issuesProcessing': How many ReprocessingReports exist for this Project
         'issuesProcessing': How many ReprocessingReports exist for this Project
-        'signedLink': Signed link that takes the user to the reprocessing page
-        for this project
         'project': Slug for the project
         'project': Slug for the project
 
 
     """
     """
@@ -46,8 +43,8 @@ def get_processing_issues(user, projects, include_detailed_issues=False):
         for result in resolved_qs.values("project").annotate(count=Count("id"))
         for result in resolved_qs.values("project").annotate(count=Count("id"))
     }
     }
 
 
+    project_issues = defaultdict(list)
     if include_detailed_issues:
     if include_detailed_issues:
-        project_issues = defaultdict(list)
         for proc_issue in (
         for proc_issue in (
             ProcessingIssue.objects.with_num_events()
             ProcessingIssue.objects.with_num_events()
             .filter(project__in=projects)
             .filter(project__in=projects)
@@ -60,17 +57,6 @@ def get_processing_issues(user, projects, include_detailed_issues=False):
         agg_results = project_agg_results.get(project.id, {})
         agg_results = project_agg_results.get(project.id, {})
         num_issues = agg_results.get("num_issues", 0)
         num_issues = agg_results.get("num_issues", 0)
 
 
-        signed_link = None
-        if num_issues > 0:
-            signed_link = generate_signed_link(
-                user,
-                "sentry-api-0-project-fix-processing-issues",
-                kwargs={
-                    "project_slug": project.slug,
-                    "organization_slug": project.organization.slug,
-                },
-            )
-
         last_seen = agg_results.get("last_seen")
         last_seen = agg_results.get("last_seen")
         data = {
         data = {
             "hasIssues": num_issues > 0,
             "hasIssues": num_issues > 0,
@@ -82,7 +68,6 @@ def get_processing_issues(user, projects, include_detailed_issues=False):
             # so that we don't break any other consumers that expect this value.
             # so that we don't break any other consumers that expect this value.
             "hasMoreResolveableIssues": False,
             "hasMoreResolveableIssues": False,
             "issuesProcessing": project_reprocessing_issues.get(project.id, 0),
             "issuesProcessing": project_reprocessing_issues.get(project.id, 0),
-            "signedLink": signed_link,
             "project": project.slug,
             "project": project.slug,
         }
         }
         if include_detailed_issues:
         if include_detailed_issues:

+ 0 - 6
src/sentry/api/urls.py

@@ -418,7 +418,6 @@ from .endpoints.project_plugins import ProjectPluginsEndpoint
 from .endpoints.project_processingissues import (
 from .endpoints.project_processingissues import (
     ProjectProcessingIssuesDiscardEndpoint,
     ProjectProcessingIssuesDiscardEndpoint,
     ProjectProcessingIssuesEndpoint,
     ProjectProcessingIssuesEndpoint,
-    ProjectProcessingIssuesFixEndpoint,
 )
 )
 from .endpoints.project_profiling_profile import (
 from .endpoints.project_profiling_profile import (
     ProjectProfilingEventEndpoint,
     ProjectProfilingEventEndpoint,
@@ -2169,11 +2168,6 @@ PROJECT_URLS = [
         ProjectProcessingIssuesEndpoint.as_view(),
         ProjectProcessingIssuesEndpoint.as_view(),
         name="sentry-api-0-project-processing-issues",
         name="sentry-api-0-project-processing-issues",
     ),
     ),
-    url(
-        r"^(?P<organization_slug>[^\/]+)/(?P<project_slug>[^\/]+)/processingissues/fix$",
-        ProjectProcessingIssuesFixEndpoint.as_view(),
-        name="sentry-api-0-project-fix-processing-issues",
-    ),
     url(
     url(
         r"^(?P<organization_slug>[^\/]+)/(?P<project_slug>[^\/]+)/reprocessing/$",
         r"^(?P<organization_slug>[^\/]+)/(?P<project_slug>[^\/]+)/reprocessing/$",
         ProjectReprocessingEndpoint.as_view(),
         ProjectReprocessingEndpoint.as_view(),

+ 0 - 63
src/sentry/templates/sentry/reprocessing-script.sh

@@ -1,63 +0,0 @@
-{% load i18n %}{% autoescape off %}#!/bin/bash
-set -eu
-SIGN=$'\033[2m>\033[0m'
-DOWNLOAD_VERSION=1.66.0
-MIN_VERSION=1.30.0
-MIN_INT_VERSION=`echo $MIN_VERSION|awk -F. '{ printf("%04d%04d%04d\n", $1, $2, $3) }'`
-
-{% if not token %}
-echo 'error: the link you followed expired.'
-exit 1
-{% elif issues %}
-echo "{% blocktrans count issues=issues|length %}Looking for {{ issues }} missing debug symbol{% plural %}Looking for {{ issues }} missing debug symbols:{% endblocktrans %}"
-{% for issue in issues %}
-  echo $'  \033[2m{{ issue.uuid }}\033[0m ({{ issue.name }}; {{ issue.arch }})'
-{% endfor %}
-echo
-
-HAVE_SENTRY_CLI=0
-if hash sentry-cli 2> /dev/null; then
-  INSTALLED_VERSION=`sentry-cli --version|awk '{print $2}'|awk -F. '{ printf("%04d%04d%04d\n", $1, $2, $3) }'`
-  if (( 10#$INSTALLED_VERSION >= 10#$MIN_INT_VERSION )); then
-    HAVE_SENTRY_CLI=1
-    CLI=sentry-cli
-  fi
-fi
-
-if [ "$HAVE_SENTRY_CLI" == "0" ]; then
-  DOWNLOAD_URL="https://github.com/getsentry/sentry-cli/releases/download/$DOWNLOAD_VERSION/sentry-cli-Darwin-x86_64"
-  TEMP_FILE=`mktemp "${TMPDIR:-/tmp}/.sentrycli.XXXXXXXX"`
-  cleanup() {
-    rm -f "$TEMP_FILE"
-  }
-  trap cleanup EXIT
-  echo "$SIGN Fetching sentry-cli utility"
-  download_start=`date +%s`
-  if ! curl -fSL --progress-bar "$DOWNLOAD_URL" -o "$TEMP_FILE" 2>&1; then
-    echo "error: could not download sentry-cli"
-    exit 1
-  fi
-  chmod +x "$TEMP_FILE"
-  download_end=`date +%s`
-  CLI="$TEMP_FILE"
-  echo -n $'\033[2A\033[K'
-  echo "$SIGN Fetched sentry-cli utility in $((download_end-download_start))s"
-  echo -n $'\033[K'
-else
-  echo "$SIGN Using installed sentry-cli utility"
-fi
-
-echo "$SIGN Looking for debug symbols"
-
-export SENTRY_AUTH_TOKEN="{{ token }}"
-export SENTRY_URL="{{ server_url }}"
-export SENTRY_ORG="{{ project.organization.slug }}"
-export SENTRY_PROJECT="{{ project.slug }}"
-
-"$CLI" upload-dsym --derived-data --no-zips{% for issue in issues %} --uuid {{ issue.uuid }}{% endfor %} --require-all
-echo
-echo $'\033[32mSuccessfully found all symbols!\033[0m'
-{% else %}
-echo 'There are currently no missing debug symbols for ``{{ project.slug }}``'
-{% endif %}
-{% endautoescape %}

+ 0 - 21
tests/integration/test_api.py

@@ -1,11 +1,8 @@
 from datetime import datetime, timedelta, timezone
 from datetime import datetime, timedelta, timezone
 
 
-from django.urls import reverse
-
 from sentry.models import AuthIdentity, AuthProvider
 from sentry.models import AuthIdentity, AuthProvider
 from sentry.testutils import AuthProviderTestCase
 from sentry.testutils import AuthProviderTestCase
 from sentry.utils.auth import SSO_EXPIRY_TIME, SsoSession
 from sentry.utils.auth import SSO_EXPIRY_TIME, SsoSession
-from sentry.utils.linksign import generate_signed_link
 
 
 
 
 # TODO: move these into the tests/sentry/auth directory and remove deprecated logic
 # TODO: move these into the tests/sentry/auth directory and remove deprecated logic
@@ -121,21 +118,3 @@ class AuthenticationTest(AuthProviderTestCase):
         for path in self.paths:
         for path in self.paths:
             resp = self.client.get(path)
             resp = self.client.get(path)
             assert resp.status_code == status, (resp.status_code, resp.content)
             assert resp.status_code == status, (resp.status_code, resp.content)
-
-    def test_sso_auth_required_signed_link(self):
-        unsigned_link = reverse(
-            "sentry-api-0-project-fix-processing-issues",
-            kwargs={"project_slug": self.project.slug, "organization_slug": self.organization.slug},
-        )
-
-        resp = self.client.get(unsigned_link)
-        assert resp.status_code == 401, (resp.status_code, resp.content)
-
-        signed_link = generate_signed_link(
-            self.user,
-            "sentry-api-0-project-fix-processing-issues",
-            kwargs={"project_slug": self.project.slug, "organization_slug": self.organization.slug},
-        )
-
-        resp = self.client.get(signed_link)
-        assert resp.status_code == 200