From fe90ddcfeee0d303ab5418b302679d1f9738186d Mon Sep 17 00:00:00 2001 From: Josh Ferge Date: Sun, 9 Nov 2025 23:38:06 -0500 Subject: [PATCH] fix(types): Add assertions for project_id and organization_id validation Add explicit assertions after None check to help mypy understand that project_id and organization_id are not None when checking if they exist. --- src/sentry/api/endpoints/prompts_activity.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sentry/api/endpoints/prompts_activity.py b/src/sentry/api/endpoints/prompts_activity.py index ffd74853602d73..11b34bf73d5a66 100644 --- a/src/sentry/api/endpoints/prompts_activity.py +++ b/src/sentry/api/endpoints/prompts_activity.py @@ -93,13 +93,17 @@ def put(self, request: Request, **kwargs): # if project_id or organization_id in required fields make sure they exist # if NOT in required fields, insert dummy value so dups aren't recorded if "project_id" in required_fields: - if not Project.objects.filter(id=fields["project_id"]).exists(): + project_id = fields["project_id"] + assert project_id is not None + if not Project.objects.filter(id=project_id).exists(): return Response({"detail": "Project no longer exists"}, status=400) else: fields["project_id"] = 0 if "organization_id" in required_fields: - if not Organization.objects.filter(id=fields["organization_id"]).exists(): + organization_id = fields["organization_id"] + assert organization_id is not None + if not Organization.objects.filter(id=organization_id).exists(): return Response({"detail": "Organization no longer exists"}, status=400) else: fields["organization_id"] = 0