prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  AttributeError /api/0/organizations/{organization_slug}/sentry-apps/
  ## Important Details
  
  How are you running Sentry?
  
  <!-- Please pick one of the following -->
  On-Premise w/ Docker, Sentry 21.1.0486d790, based on https://github.com/Rungutan/sentry-performance-monitoring
  
  ## Description
  
  Opening of these sub items in "Organization" settings fails:
  * Audit Log
  * Integrations
  * Developer settings
  
  This seems to be the resulting issue in the "Internal" Sentry project:
  ```
  AttributeError: 'NoneType' object has no attribute 'get_allowed_origins'
    File "sentry/api/base.py", line 124, in handle_exception
      response = super(Endpoint, self).handle_exception(exc)
    File "rest_framework/views.py", line 449, in handle_exception
      self.raise_uncaught_exception(exc)
    File "sentry/api/base.py", line 237, in dispatch
      response = handler(request, *args, **kwargs)
    File "sentry/api/bases/sentryapps.py", line 59, in wrapped
      return func(self, *args, **kwargs)
    File "sentry/api/endpoints/organization_sentry_apps.py", line 19, in get
      on_results=lambda x: serialize(x, request.user, access=request.access),
    File "sentry/api/base.py", line 330, in paginate
      results = on_results(cursor_result.results)
    File "sentry/api/endpoints/organization_sentry_apps.py", line 19, in <lambda>
      on_results=lambda x: serialize(x, request.user, access=request.access),
    File "sentry/api/serializers/base.py", line 45, in serialize
      return [serializer(o, attrs=attrs.get(o, {}), user=user, **kwargs) for o in objects]
    File "sentry/api/serializers/base.py", line 45, in <listcomp>
      return [serializer(o, attrs=attrs.get(o, {}), user=user, **kwargs) for o in objects]
    File "sentry/api/serializers/base.py", line 60, in __call__
      return self.serialize(obj, attrs, user, **kwargs)
    File "sentry/api/serializers/models/sentry_app.py", line 31, in serialize
      "allowedOrigins": obj.application.get_allowed_origins(),
  ```
  
  Last SQL before exception
  
  ```
  SELECT "sentry_organization"."id", "sentry_organization"."name", "sentry_organization"."slug", "sentry_organization"."status", "sentry_organization"."date_added", "sentry_organization"."default_role", "sentry_organization"."flags" FROM "sentry_organization" WHERE "sentry_organization"."id" = %s
  ```
  
  ### What you expected to happen
  Menus should work.
  
  ### Possible Solution
  
  [If you have an idea on how this could be solved include that detail here.]
  
  
  </issue>
  <code>
  [start of src/sentry/api/endpoints/organization_sentry_apps.py]
  1 from sentry.api.bases import OrganizationEndpoint, add_integration_platform_metric_tag
  2 from sentry.api.paginator import OffsetPaginator
  3 from sentry.api.serializers import serialize
  4 from sentry.models import SentryApp
  5 
  6 
  7 class OrganizationSentryAppsEndpoint(OrganizationEndpoint):
  8     @add_integration_platform_metric_tag
  9     def get(self, request, organization):
  10         queryset = SentryApp.objects.filter(owner=organization)
  11 
  12         return self.paginate(
  13             request=request,
  14             queryset=queryset,
  15             order_by="-date_added",
  16             paginator_cls=OffsetPaginator,
  17             on_results=lambda x: serialize(x, request.user, access=request.access),
  18         )
  19
  [end of src/sentry/api/endpoints/organization_sentry_apps.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/sentry/api/endpoints/organization_sentry_apps.py b/src/sentry/api/endpoints/organization_sentry_apps.py
  --- a/src/sentry/api/endpoints/organization_sentry_apps.py
  +++ b/src/sentry/api/endpoints/organization_sentry_apps.py
  @@ -7,7 +7,7 @@
   class OrganizationSentryAppsEndpoint(OrganizationEndpoint):
       @add_integration_platform_metric_tag
       def get(self, request, organization):
  -        queryset = SentryApp.objects.filter(owner=organization)
  +        queryset = SentryApp.objects.filter(owner=organization, application__isnull=False)
   
           return self.paginate(
               request=request,
  
verification_info: {"golden_diff": "diff --git a/src/sentry/api/endpoints/organization_sentry_apps.py b/src/sentry/api/endpoints/organization_sentry_apps.py\n--- a/src/sentry/api/endpoints/organization_sentry_apps.py\n+++ b/src/sentry/api/endpoints/organization_sentry_apps.py\n@@ -7,7 +7,7 @@\n class OrganizationSentryAppsEndpoint(OrganizationEndpoint):\n     @add_integration_platform_metric_tag\n     def get(self, request, organization):\n-        queryset = SentryApp.objects.filter(owner=organization)\n+        queryset = SentryApp.objects.filter(owner=organization, application__isnull=False)\n \n         return self.paginate(\n             request=request,\n", "issue": "AttributeError /api/0/organizations/{organization_slug}/sentry-apps/\n## Important Details\r\n\r\nHow are you running Sentry?\r\n\r\n<!-- Please pick one of the following -->\r\nOn-Premise w/ Docker, Sentry 21.1.0486d790, based on https://github.com/Rungutan/sentry-performance-monitoring\r\n\r\n## Description\r\n\r\nOpening of these sub items in \"Organization\" settings fails:\r\n* Audit Log\r\n* Integrations\r\n* Developer settings\r\n\r\nThis seems to be the resulting issue in the \"Internal\" Sentry project:\r\n```\r\nAttributeError: 'NoneType' object has no attribute 'get_allowed_origins'\r\n  File \"sentry/api/base.py\", line 124, in handle_exception\r\n    response = super(Endpoint, self).handle_exception(exc)\r\n  File \"rest_framework/views.py\", line 449, in handle_exception\r\n    self.raise_uncaught_exception(exc)\r\n  File \"sentry/api/base.py\", line 237, in dispatch\r\n    response = handler(request, *args, **kwargs)\r\n  File \"sentry/api/bases/sentryapps.py\", line 59, in wrapped\r\n    return func(self, *args, **kwargs)\r\n  File \"sentry/api/endpoints/organization_sentry_apps.py\", line 19, in get\r\n    on_results=lambda x: serialize(x, request.user, access=request.access),\r\n  File \"sentry/api/base.py\", line 330, in paginate\r\n    results = on_results(cursor_result.results)\r\n  File \"sentry/api/endpoints/organization_sentry_apps.py\", line 19, in <lambda>\r\n    on_results=lambda x: serialize(x, request.user, access=request.access),\r\n  File \"sentry/api/serializers/base.py\", line 45, in serialize\r\n    return [serializer(o, attrs=attrs.get(o, {}), user=user, **kwargs) for o in objects]\r\n  File \"sentry/api/serializers/base.py\", line 45, in <listcomp>\r\n    return [serializer(o, attrs=attrs.get(o, {}), user=user, **kwargs) for o in objects]\r\n  File \"sentry/api/serializers/base.py\", line 60, in __call__\r\n    return self.serialize(obj, attrs, user, **kwargs)\r\n  File \"sentry/api/serializers/models/sentry_app.py\", line 31, in serialize\r\n    \"allowedOrigins\": obj.application.get_allowed_origins(),\r\n```\r\n\r\nLast SQL before exception\r\n\r\n```\r\nSELECT \"sentry_organization\".\"id\", \"sentry_organization\".\"name\", \"sentry_organization\".\"slug\", \"sentry_organization\".\"status\", \"sentry_organization\".\"date_added\", \"sentry_organization\".\"default_role\", \"sentry_organization\".\"flags\" FROM \"sentry_organization\" WHERE \"sentry_organization\".\"id\" = %s\r\n```\r\n\r\n### What you expected to happen\r\nMenus should work.\r\n\r\n### Possible Solution\r\n\r\n[If you have an idea on how this could be solved include that detail here.]\r\n\n", "before_files": [{"content": "from sentry.api.bases import OrganizationEndpoint, add_integration_platform_metric_tag\nfrom sentry.api.paginator import OffsetPaginator\nfrom sentry.api.serializers import serialize\nfrom sentry.models import SentryApp\n\n\nclass OrganizationSentryAppsEndpoint(OrganizationEndpoint):\n    @add_integration_platform_metric_tag\n    def get(self, request, organization):\n        queryset = SentryApp.objects.filter(owner=organization)\n\n        return self.paginate(\n            request=request,\n            queryset=queryset,\n            order_by=\"-date_added\",\n            paginator_cls=OffsetPaginator,\n            on_results=lambda x: serialize(x, request.user, access=request.access),\n        )\n", "path": "src/sentry/api/endpoints/organization_sentry_apps.py"}]}