Skip to content

Commit

Permalink
ref: fix passing slug=None to HC slug check (#73121)
Browse files Browse the repository at this point in the history
this currently produces an INFO log on every logged out request

```
16:38:59 server  | 16:38:59 [INFO] sentry.services.hybrid_cloud: Organization by slug [None] not found
```

this fixes these two type errors as well:

```
src/sentry/web/frontend/auth_login.py:509: error: Argument "slug" to "check_organization_by_slug" of "OrganizationService" has incompatible type "str | None"; expected "str"  [arg-type]
src/sentry/web/frontend/auth_login.py:568: error: Argument "slug" to "check_organization_by_slug" of "OrganizationService" has incompatible type "str | None"; expected "str"  [arg-type]
```

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jun 21, 2024
1 parent 758a9df commit 7281bbf
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/sentry/web/frontend/auth_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,11 @@ def org_exists(self, request: Request) -> bool:
"""
Returns True if the organization passed in a request exists.
"""
return bool(
return request.subdomain is not None and (
organization_service.check_organization_by_slug(
slug=request.subdomain, only_visible=True
)
is not None
)

def can_register(self, request: Request) -> bool:
Expand Down Expand Up @@ -563,13 +564,7 @@ def handle_basic_auth(self, request: Request, **kwargs) -> HttpResponseBase:
op = request.POST.get("op")
organization = kwargs.pop("organization", None)

org_exists = bool(
organization_service.check_organization_by_slug(
slug=request.subdomain, only_visible=True
)
)

if request.method == "GET" and request.subdomain and org_exists:
if request.method == "GET" and request.subdomain and self.org_exists(request):
urls = [
reverse("sentry-auth-organization", args=[request.subdomain]),
reverse("sentry-register"),
Expand Down

0 comments on commit 7281bbf

Please sign in to comment.