Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/sentry/api/endpoints/debug_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,11 @@ def delete(self, request: Request, project: Project) -> Response:
:qparam string id: The id of the DIF to delete.
:auth: required
"""
if request.GET.get("id") and _has_delete_permission(request.access, project):
debug_file_id = request.GET.get("id")
if debug_file_id and _has_delete_permission(request.access, project):
with atomic_transaction(using=router.db_for_write(File)):
debug_file = (
ProjectDebugFile.objects.filter(id=request.GET.get("id"), project_id=project.id) # type: ignore[misc]
ProjectDebugFile.objects.filter(id=debug_file_id, project_id=project.id)
.select_related("file")
.first()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,18 @@ def semver_build_autocomplete_function(self):
]

def semver_package_autocomplete_function(self):
assert self.snuba_params.organization_id is not None
packages = (
Release.objects.filter(
organization_id=self.snuba_params.organization_id, # type: ignore[misc]
organization_id=self.snuba_params.organization_id,
package__startswith=self.query,
)
.values_list("package")
.distinct()
)

versions = Release.objects.filter(
organization_id=self.snuba_params.organization_id, # type: ignore[misc]
organization_id=self.snuba_params.organization_id,
package__in=packages,
id__in=ReleaseProject.objects.filter(
project_id__in=self.snuba_params.project_ids
Expand Down
5 changes: 4 additions & 1 deletion src/sentry/integrations/vercel/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ def post_install(
)
return

user = User.objects.get(id=extra.get("user_id")) # type: ignore[misc]
user_id = extra.get("user_id")
if user_id is None:
raise ValueError("user_id is required in post_install_data")
user = User.objects.get(id=user_id)
# create the internal integration and link it to the join table
sentry_app = SentryAppCreator(
name="Vercel Internal Integration",
Expand Down
4 changes: 3 additions & 1 deletion src/sentry/integrations/vsts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ def __init__(
def identity(self):
if self._identity:
return self._identity
self._identity = Identity.objects.get(id=self.identity_id) # type: ignore[misc]
if self.identity_id is None:
raise ValueError("identity_id is not set")
self._identity = Identity.objects.get(id=self.identity_id)
return self._identity

def request(self, method: str, *args: Any, **kwargs: Any) -> Any:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def get(self, request: Request, organization: Organization) -> Response:
Retrieve a list of starred views for the current organization member.
"""

assert request.user.id is not None
starred_views = GroupSearchViewStarred.objects.filter(
organization=organization, user_id=request.user.id # type: ignore[misc]
organization=organization, user_id=request.user.id
).select_related("group_search_view")

return self.paginate(
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/users/api/endpoints/user_authenticator_enroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def post(self, request: Request, user: User, interface_id: str) -> HttpResponse:

# Using `request.user` here because superuser/staff should not be able to set a user's 2fa
if user.id != request.user.id:
user = User.objects.get(id=request.user.id) # type: ignore[misc]
assert request.user.id is not None
user = User.objects.get(id=request.user.id)

# start activation
serializer_cls = serializer_map.get(interface_id, None)
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/users/models/user_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def unset_value(self, user: User, project: Project, key: str) -> None:
"""
This isn't implemented for user-organization scoped options yet, because it hasn't been needed.
"""
self.filter(user=user, project=project, key=key).delete() # type: ignore[misc]
self.filter(user=user, project_id=project.id, key=key).delete()

if not hasattr(self, "_metadata"):
return
Expand Down
Loading