π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
fix: uuid validation, status and webhook errors (#6896)
Nikhilbfc6ed839f4c
diff --git a/apiserver/plane/api/views/cycle.py b/apiserver/plane/api/views/cycle.pyindex 3288c17502..3e27ffdc42 100644--- a/apiserver/plane/api/views/cycle.py+++ b/apiserver/plane/api/views/cycle.py@@ -141,8 +141,10 @@ class CycleAPIEndpoint(BaseAPIView):if pk:queryset = self.get_queryset().filter(archived_at__isnull=True).get(pk=pk)data = CycleSerializer(- queryset, fields=self.fields,- expand=self.expand, context={"project": project}+ queryset,+ fields=self.fields,+ expand=self.expand,+ context={"project": project},).datareturn Response(data, status=status.HTTP_200_OK)queryset = self.get_queryset().filter(archived_at__isnull=True)@@ -154,8 +156,11 @@ class CycleAPIEndpoint(BaseAPIView):start_date__lte=timezone.now(), end_date__gte=timezone.now())data = CycleSerializer(- queryset, many=True, fields=self.fields,- expand=self.expand, context={"project": project}+ queryset,+ many=True,+ fields=self.fields,+ expand=self.expand,+ context={"project": project},).datareturn Response(data, status=status.HTTP_200_OK)@@ -166,8 +171,11 @@ class CycleAPIEndpoint(BaseAPIView):request=request,queryset=(queryset),on_results=lambda cycles: CycleSerializer(- cycles, many=True, fields=self.fields,- expand=self.expand, context={"project": project}+ cycles,+ many=True,+ fields=self.fields,+ expand=self.expand,+ context={"project": project},).data,)@@ -178,8 +186,11 @@ class CycleAPIEndpoint(BaseAPIView):request=request,queryset=(queryset),on_results=lambda cycles: CycleSerializer(- cycles, many=True, fields=self.fields,- expand=self.expand, context={"project": project}+ cycles,+ many=True,+ fields=self.fields,+ expand=self.expand,+ context={"project": project},).data,)@@ -190,8 +201,11 @@ class CycleAPIEndpoint(BaseAPIView):request=request,queryset=(queryset),on_results=lambda cycles: CycleSerializer(- cycles, many=True, fields=self.fields,- expand=self.expand, context={"project": project}+ cycles,+ many=True,+ fields=self.fields,+ expand=self.expand,+ context={"project": project},).data,)@@ -204,16 +218,22 @@ class CycleAPIEndpoint(BaseAPIView):request=request,queryset=(queryset),on_results=lambda cycles: CycleSerializer(- cycles, many=True, fields=self.fields,- expand=self.expand, context={"project": project}+ cycles,+ many=True,+ fields=self.fields,+ expand=self.expand,+ context={"project": project},).data,)return self.paginate(request=request,queryset=(queryset),on_results=lambda cycles: CycleSerializer(- cycles, many=True, fields=self.fields,- expand=self.expand, context={"project": project}+ cycles,+ many=True,+ fields=self.fields,+ expand=self.expand,+ context={"project": project},).data,)diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.pyindex e0aee3a205..efbdf07f9b 100644--- a/apiserver/plane/api/views/issue.py+++ b/apiserver/plane/api/views/issue.py@@ -57,6 +57,7 @@ from plane.settings.storage import S3Storagefrom plane.bgtasks.storage_metadata_task import get_asset_object_metadatafrom .base import BaseAPIViewfrom plane.utils.host import base_host+from plane.bgtasks.webhook_task import model_activityclass WorkspaceIssueAPIEndpoint(BaseAPIView):@@ -322,6 +323,17 @@ class IssueAPIEndpoint(BaseAPIView):current_instance=None,epoch=int(timezone.now().timestamp()),)++ # Send the model activity+ model_activity.delay(+ model_name="issue",+ model_id=str(serializer.data["id"]),+ requested_data=request.data,+ current_instance=None,+ actor_id=request.user.id,+ slug=slug,+ origin=base_host(request=request, is_app=True),+ )return Response(serializer.data, status=status.HTTP_201_CREATED)return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.pyindex 289f1d0148..5ceb06a63a 100644--- a/apiserver/plane/api/views/project.py+++ b/apiserver/plane/api/views/project.py@@ -32,6 +32,7 @@ from plane.bgtasks.webhook_task import model_activity, webhook_activityfrom .base import BaseAPIViewfrom plane.utils.host import base_host+class ProjectAPIEndpoint(BaseAPIView):"""Project Endpoints to create, update, list, retrieve and delete endpoint"""@@ -238,7 +239,7 @@ class ProjectAPIEndpoint(BaseAPIView):if "already exists" in str(e):return Response({"name": "The project name is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)except Workspace.DoesNotExist:return Response(@@ -247,7 +248,7 @@ class ProjectAPIEndpoint(BaseAPIView):except ValidationError:return Response({"identifier": "The project identifier is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)def patch(self, request, slug, pk):@@ -305,7 +306,7 @@ class ProjectAPIEndpoint(BaseAPIView):if "already exists" in str(e):return Response({"name": "The project name is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)except (Project.DoesNotExist, Workspace.DoesNotExist):return Response(@@ -314,7 +315,7 @@ class ProjectAPIEndpoint(BaseAPIView):except ValidationError:return Response({"identifier": "The project identifier is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)def delete(self, request, slug, pk):diff --git a/apiserver/plane/app/views/project/base.py b/apiserver/plane/app/views/project/base.pyindex f5089b44fd..46290d7a55 100644--- a/apiserver/plane/app/views/project/base.py+++ b/apiserver/plane/app/views/project/base.py@@ -41,6 +41,7 @@ from plane.bgtasks.recent_visited_task import recent_visited_taskfrom plane.utils.exception_logger import log_exceptionfrom plane.utils.host import base_host+class ProjectViewSet(BaseViewSet):serializer_class = ProjectListSerializermodel = Project@@ -341,7 +342,7 @@ class ProjectViewSet(BaseViewSet):if "already exists" in str(e):return Response({"name": "The project name is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)except Workspace.DoesNotExist:return Response(@@ -350,7 +351,7 @@ class ProjectViewSet(BaseViewSet):except serializers.ValidationError:return Response({"identifier": "The project identifier is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)def partial_update(self, request, slug, pk=None):@@ -419,7 +420,7 @@ class ProjectViewSet(BaseViewSet):if "already exists" in str(e):return Response({"name": "The project name is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)except (Project.DoesNotExist, Workspace.DoesNotExist):return Response(@@ -428,7 +429,7 @@ class ProjectViewSet(BaseViewSet):except serializers.ValidationError:return Response({"identifier": "The project identifier is already taken"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)def destroy(self, request, slug, pk):diff --git a/apiserver/plane/app/views/webhook/base.py b/apiserver/plane/app/views/webhook/base.pyindex d7ff5cf3ab..0ed4ba9e0b 100644--- a/apiserver/plane/app/views/webhook/base.py+++ b/apiserver/plane/app/views/webhook/base.py@@ -29,7 +29,7 @@ class WebhookEndpoint(BaseAPIView):if "already exists" in str(e):return Response({"error": "URL already exists for the workspace"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)raise IntegrityErrordiff --git a/apiserver/plane/app/views/workspace/base.py b/apiserver/plane/app/views/workspace/base.pyindex 5be9a7558c..c627f19b6b 100644--- a/apiserver/plane/app/views/workspace/base.py+++ b/apiserver/plane/app/views/workspace/base.py@@ -119,7 +119,9 @@ class WorkSpaceViewSet(BaseViewSet):)# Get total members and role- total_members=WorkspaceMember.objects.filter(workspace_id=serializer.data["id"]).count()+ total_members = WorkspaceMember.objects.filter(+ workspace_id=serializer.data["id"]+ ).count()data = serializer.datadata["total_members"] = total_membersdata["role"] = 20@@ -134,7 +136,7 @@ class WorkSpaceViewSet(BaseViewSet):if "already exists" in str(e):return Response({"slug": "The workspace with the slug already exists"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST], level="WORKSPACE")@@ -167,10 +169,9 @@ class UserWorkSpacesEndpoint(BaseAPIView):.values("count"))- role = (- WorkspaceMember.objects.filter(workspace=OuterRef("id"), member=request.user, is_active=True)- .values("role")- )+ role = WorkspaceMember.objects.filter(+ workspace=OuterRef("id"), member=request.user, is_active=True+ ).values("role")workspace = (Workspace.objects.prefetch_related(diff --git a/apiserver/plane/bgtasks/issue_activities_task.py b/apiserver/plane/bgtasks/issue_activities_task.pyindex 13bef73a2c..827534a211 100644--- a/apiserver/plane/bgtasks/issue_activities_task.py+++ b/apiserver/plane/bgtasks/issue_activities_task.py@@ -307,6 +307,10 @@ def track_labels(# Set of newly added labelsfor added_label in added_labels:+ # validate uuids+ if not is_valid_uuid(added_label):+ continue+label = Label.objects.get(pk=added_label)issue_activities.append(IssueActivity(@@ -327,6 +331,10 @@ def track_labels(# Set of dropped labelsfor dropped_label in dropped_labels:+ # validate uuids+ if not is_valid_uuid(dropped_label):+ continue+label = Label.objects.get(pk=dropped_label)issue_activities.append(IssueActivity(@@ -373,6 +381,10 @@ def track_assignees(bulk_subscribers = []for added_asignee in added_assignees:+ # validate uuids+ if not is_valid_uuid(added_asignee):+ continue+assignee = User.objects.get(pk=added_asignee)issue_activities.append(IssueActivity(@@ -406,6 +418,10 @@ def track_assignees()for dropped_assignee in dropped_assginees:+ # validate uuids+ if not is_valid_uuid(dropped_assignee):+ continue+assignee = User.objects.get(pk=dropped_assignee)issue_activities.append(IssueActivity(diff --git a/apiserver/plane/license/api/views/workspace.py b/apiserver/plane/license/api/views/workspace.pyindex 607016cc3a..8b5eaac6b3 100644--- a/apiserver/plane/license/api/views/workspace.py+++ b/apiserver/plane/license/api/views/workspace.py@@ -109,5 +109,5 @@ class InstanceWorkSpaceEndpoint(BaseAPIView):if "already exists" in str(e):return Response({"slug": "The workspace with the slug already exists"},- status=status.HTTP_410_GONE,+ status=status.HTTP_409_CONFLICT,)diff --git a/apiserver/plane/tests/api/test_workspace.py b/apiserver/plane/tests/api/test_workspace.pyindex c1e487fbed..d63eab2e09 100644--- a/apiserver/plane/tests/api/test_workspace.py+++ b/apiserver/plane/tests/api/test_workspace.py@@ -41,4 +41,4 @@ class WorkSpaceCreateReadUpdateDelete(AuthenticatedAPITest):response = self.client.post(url, {"name": "Plane", "slug": "pla-ne"}, format="json")- self.assertEqual(response.status_code, status.HTTP_410_GONE)+ self.assertEqual(response.status_code, status.HTTP_409_CONFLICT)