Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(conversations): bulk manage tags on tickets (#74760)

Christian Rafferty9d5418f3f7d4
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index 89a6922feb47..b67061d61ade 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -4073,7 +4073,11 @@ export interface BulkUpdateTagsRequestApi {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnumApi
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[]
}
diff --git a/frontend/src/generated/core/api.zod.ts b/frontend/src/generated/core/api.zod.ts
index a3bc461dec07..42d3491b6517 100644
--- a/frontend/src/generated/core/api.zod.ts
+++ b/frontend/src/generated/core/api.zod.ts
@@ -979,6 +979,10 @@ export const PropertyDefinitionsPartialUpdateBody = /* @__PURE__ */ zod
*/
export const propertyDefinitionsBulkUpdateTagsCreateBodyIdsMax = 500
+export const propertyDefinitionsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const propertyDefinitionsBulkUpdateTagsCreateBodyTagsMax = 100
+
export const PropertyDefinitionsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
ids: zod
.array(zod.number())
@@ -990,7 +994,10 @@ export const PropertyDefinitionsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.o
.describe(
"'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
+ tags: zod
+ .array(zod.string().max(propertyDefinitionsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(propertyDefinitionsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
})
/**
diff --git a/frontend/src/lib/components/BulkActions/BulkUpdateTagsButton.tsx b/frontend/src/lib/components/BulkActions/BulkUpdateTagsButton.tsx
index 610edd44cd8e..ccf08b8807ff 100644
--- a/frontend/src/lib/components/BulkActions/BulkUpdateTagsButton.tsx
+++ b/frontend/src/lib/components/BulkActions/BulkUpdateTagsButton.tsx
@@ -11,12 +11,22 @@ export type { BulkTagAction, BulkTaggableResource, BulkUpdateTagsResult } from '
interface BulkUpdateTagsButtonProps {
resource: BulkTaggableResource
- // Integer PKs for most resources; event definitions are keyed by UUID strings.
+ // Integer PKs for most resources; event definitions and tickets are keyed by UUID strings.
selectedIds: ReadonlyArray<number | string>
onSuccess?: (result: BulkUpdateTagsResult) => void
+ /** Disables the trigger with an explanatory tooltip, for toolbars that render it before any selection exists. */
+ disabledReason?: string
+ /** Tooltip on the enabled trigger, e.g. a partial-selection warning. */
+ tooltip?: string
}
-export function BulkUpdateTagsButton({ resource, selectedIds, onSuccess }: BulkUpdateTagsButtonProps): JSX.Element {
+export function BulkUpdateTagsButton({
+ resource,
+ selectedIds,
+ onSuccess,
+ disabledReason,
+ tooltip,
+}: BulkUpdateTagsButtonProps): JSX.Element {
const [visible, setVisible] = useState(false)
return (
@@ -35,7 +45,14 @@ export function BulkUpdateTagsButton({ resource, selectedIds, onSuccess }: BulkU
</div>
}
>
- <LemonButton type="secondary" size="small" icon={<IconPencil />} onClick={() => setVisible(true)}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconPencil />}
+ onClick={() => setVisible(true)}
+ disabledReason={disabledReason}
+ tooltip={tooltip}
+ >
Update tags
</LemonButton>
</Popover>
diff --git a/frontend/src/lib/components/BulkActions/BulkUpdateTagsForm.tsx b/frontend/src/lib/components/BulkActions/BulkUpdateTagsForm.tsx
index a1a95d20b263..693a89d40c44 100644
--- a/frontend/src/lib/components/BulkActions/BulkUpdateTagsForm.tsx
+++ b/frontend/src/lib/components/BulkActions/BulkUpdateTagsForm.tsx
@@ -17,11 +17,16 @@ export interface BulkUpdateTagsResult {
skipped: Array<{ id: number | string; reason: string }>
}
-export type BulkTaggableResource = 'feature_flags' | 'dashboards' | 'insights' | 'event_definitions'
+export type BulkTaggableResource =
+ | 'feature_flags'
+ | 'dashboards'
+ | 'insights'
+ | 'event_definitions'
+ | 'conversations/tickets'
export interface BulkUpdateTagsFormProps {
resource: BulkTaggableResource
- // Integer PKs for most resources; event definitions are keyed by UUID strings.
+ // Integer PKs for most resources; event definitions and tickets are keyed by UUID strings.
selectedIds: ReadonlyArray<number | string>
onSuccess?: (result: BulkUpdateTagsResult) => void
/** Closes the host (popover or modal). Called on Cancel and after a successful submit. */
diff --git a/posthog/api/tagged_item.py b/posthog/api/tagged_item.py
index d7d2b058e1c8..4e36ba389a63 100644
--- a/posthog/api/tagged_item.py
+++ b/posthog/api/tagged_item.py
@@ -1,6 +1,7 @@
import dataclasses
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Any, Optional, cast
+from uuid import UUID
from django.db import models
from django.db.models import Prefetch, Q, QuerySet, prefetch_related_objects
@@ -198,6 +199,11 @@ class TaggedItemSerializerMixin(serializers.Serializer):
BULK_UPDATE_TAGS_MAX_IDS = 500
+BULK_UPDATE_TAGS_MAX_TAGS = 100
+# Tags are written with a get_or_create per (object, tag), so ids × distinct tags is the unit of
+# database work a single request can demand; bound the product, not just each list, or 500 ids
+# with 100 tags each still turns one request into 50k writes.
+BULK_UPDATE_TAGS_MAX_OPERATIONS = 10_000
class BulkUpdateTagsAction(models.TextChoices):
@@ -218,13 +224,21 @@ class BulkUpdateTagsRequestSerializer(serializers.Serializer):
help_text="'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.",
)
tags = serializers.ListField(
- child=serializers.CharField(),
+ child=serializers.CharField(max_length=255),
+ max_length=BULK_UPDATE_TAGS_MAX_TAGS,
help_text="Tag names to add, remove, or set.",
)
def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
if attrs["action"] in ("add", "remove") and not attrs.get("tags"):
raise serializers.ValidationError({"tags": f"tags must not be empty for action '{attrs['action']}'."})
+ distinct_tags = {tagify(tag) for tag in attrs.get("tags", [])}
+ if len(attrs["ids"]) * len(distinct_tags) > BULK_UPDATE_TAGS_MAX_OPERATIONS:
+ raise serializers.ValidationError(
+ {
+ "tags": f"Too many changes in one request: ids × distinct tags must not exceed {BULK_UPDATE_TAGS_MAX_OPERATIONS}."
+ }
+ )
return attrs
@@ -302,6 +316,10 @@ class TaggedItemViewSetMixin(viewsets.GenericViewSet):
# bulk tag edits, which leaves their behavior unchanged.
bulk_tag_activity_scope: Optional[str] = None
+ # Request serializer for ``bulk_update_tags``. UUID-PK resources set the UUID variant and must
+ # also override the action's OpenAPI schema via ``@extend_schema_view`` on the viewset class.
+ bulk_update_tags_request_serializer_class: type[BulkUpdateTagsRequestSerializer] = BulkUpdateTagsRequestSerializer
+
def _bulk_tag_activity_context(self) -> Optional[BulkTagActivityContext]:
if not self.bulk_tag_activity_scope:
return None
@@ -370,11 +388,11 @@ class TaggedItemViewSetMixin(viewsets.GenericViewSet):
- "remove": Remove specific tags from each object
- "set": Replace all tags on each object with the provided list
"""
- serializer = BulkUpdateTagsRequestSerializer(data=request.data)
+ serializer = self.bulk_update_tags_request_serializer_class(data=request.data)
serializer.is_valid(raise_exception=True)
validated = serializer.validated_data
- validated_ids: list[int] = validated["ids"]
+ validated_ids: list[int | UUID] = validated["ids"]
tag_action: str = validated["action"]
tags: list[str] = validated["tags"]
diff --git a/posthog/api/test/test_tagged_item.py b/posthog/api/test/test_tagged_item.py
index a4a744554b8e..386b202ef5ee 100644
--- a/posthog/api/test/test_tagged_item.py
+++ b/posthog/api/test/test_tagged_item.py
@@ -1,8 +1,19 @@
+from uuid import uuid4
+
from posthog.test.base import APIBaseTest
+from django.test import SimpleTestCase
+
from parameterized import parameterized
from rest_framework import status
+from posthog.api.tagged_item import (
+ BULK_UPDATE_TAGS_MAX_IDS,
+ BULK_UPDATE_TAGS_MAX_OPERATIONS,
+ BULK_UPDATE_TAGS_MAX_TAGS,
+ BulkUpdateTagsRequestSerializer,
+ BulkUpdateTagsUUIDRequestSerializer,
+)
from posthog.models import ActivityLog, Organization, Tag, Team
from posthog.models.tagged_item import TaggedItem
@@ -415,3 +426,43 @@ class TestBulkUpdateTags(APIBaseTest):
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.json()["type"] == "validation_error"
assert response.json()["attr"] == "ids"
+
+
+SERIALIZER_VARIANTS = [
+ ("int_ids", BulkUpdateTagsRequestSerializer, lambda n: list(range(n))),
+ ("uuid_ids", BulkUpdateTagsUUIDRequestSerializer, lambda n: [str(uuid4()) for _ in range(n)]),
+]
+
+
+class TestBulkUpdateTagsRequestValidation(SimpleTestCase):
+ @parameterized.expand(SERIALIZER_VARIANTS)
+ def test_rejects_too_many_tags(self, _name, serializer_class, make_ids):
+ serializer = serializer_class(
+ data={
+ "ids": make_ids(1),
+ "action": "add",
+ "tags": [f"tag-{i}" for i in range(BULK_UPDATE_TAGS_MAX_TAGS + 1)],
+ }
+ )
+ assert not serializer.is_valid()
+ assert "tags" in serializer.errors
+
+ @parameterized.expand(SERIALIZER_VARIANTS)
+ def test_rejects_tag_longer_than_tag_name_column(self, _name, serializer_class, make_ids):
+ serializer = serializer_class(data={"ids": make_ids(1), "action": "add", "tags": ["x" * 256]})
+ assert not serializer.is_valid()
+ assert "tags" in serializer.errors
+
+ @parameterized.expand(SERIALIZER_VARIANTS)
+ def test_rejects_ids_times_distinct_tags_over_cap(self, _name, serializer_class, make_ids):
+ tags = [f"tag-{i}" for i in range(BULK_UPDATE_TAGS_MAX_OPERATIONS // BULK_UPDATE_TAGS_MAX_IDS + 1)]
+ serializer = serializer_class(data={"ids": make_ids(BULK_UPDATE_TAGS_MAX_IDS), "action": "add", "tags": tags})
+ assert not serializer.is_valid()
+ assert "must not exceed" in str(serializer.errors["tags"][0])
+
+ @parameterized.expand(SERIALIZER_VARIANTS)
+ def test_duplicate_tags_count_once_toward_the_cap(self, _name, serializer_class, make_ids):
+ # 100 entries normalizing to 20 distinct tags: 500 ids x 20 tags == the cap, not over it.
+ tags = [f"Tag-{i % 20}" for i in range(BULK_UPDATE_TAGS_MAX_TAGS)]
+ serializer = serializer_class(data={"ids": make_ids(BULK_UPDATE_TAGS_MAX_IDS), "action": "add", "tags": tags})
+ assert serializer.is_valid(), serializer.errors
diff --git a/products/actions/frontend/generated/api.schemas.ts b/products/actions/frontend/generated/api.schemas.ts
index 68ba8ce58025..327f8b742f44 100644
--- a/products/actions/frontend/generated/api.schemas.ts
+++ b/products/actions/frontend/generated/api.schemas.ts
@@ -695,7 +695,11 @@ export interface BulkUpdateTagsRequestApi {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnumApi
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[]
}
diff --git a/products/actions/frontend/generated/api.zod.ts b/products/actions/frontend/generated/api.zod.ts
index a57c43fff8ef..27e3d24ad07d 100644
--- a/products/actions/frontend/generated/api.zod.ts
+++ b/products/actions/frontend/generated/api.zod.ts
@@ -1301,6 +1301,10 @@ export const ActionsPartialUpdateBody = /* @__PURE__ */ zod
*/
export const actionsBulkUpdateTagsCreateBodyIdsMax = 500
+export const actionsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const actionsBulkUpdateTagsCreateBodyTagsMax = 100
+
export const ActionsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
ids: zod
.array(zod.number())
@@ -1312,5 +1316,8 @@ export const ActionsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
.describe(
"'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
+ tags: zod
+ .array(zod.string().max(actionsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(actionsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
})
diff --git a/products/conversations/backend/api/tests/test_tickets.py b/products/conversations/backend/api/tests/test_tickets.py
index e94c8b4914ea..11078f40bd81 100644
--- a/products/conversations/backend/api/tests/test_tickets.py
+++ b/products/conversations/backend/api/tests/test_tickets.py
@@ -1037,6 +1037,106 @@ class TestBulkUpdateStatus(APIBaseTest):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+class TestBulkUpdateTicketTags(APIBaseTest):
+ def setUp(self):
+ super().setUp()
+ self.tickets = [
+ Ticket.objects.create_with_number(
+ team=self.team,
+ channel_source=Channel.WIDGET,
+ widget_session_id=f"sess-{i}",
+ distinct_id=f"user-{i}",
+ status=Status.NEW,
+ )
+ for i in range(3)
+ ]
+
+ def _bulk_url(self) -> str:
+ return f"/api/projects/{self.team.id}/conversations/tickets/bulk_update_tags/"
+
+ def _ticket_tags(self, ticket: Ticket) -> set[str]:
+ return set(ticket.tagged_items.values_list("tag__name", flat=True))
+
+ def test_bulk_add_tags_with_uuid_ids(self):
+ ids = [str(t.id) for t in self.tickets]
+ response = self.client.post(
+ self._bulk_url(),
+ {"ids": ids, "action": "add", "tags": ["billing", "urgent"]},
+ format="json",
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ data = response.json()
+ self.assertEqual({row["id"] for row in data["updated"]}, set(ids))
+ self.assertEqual(data["skipped"], [])
+ for ticket in self.tickets:
+ self.assertEqual(self._ticket_tags(ticket), {"billing", "urgent"})
+
+ def test_other_team_ids_reported_not_found(self):
+ other_org = Organization.objects.create(name="Other Org")
+ other_team = self.create_team_with_organization(organization=other_org)
+ other_ticket = Ticket.objects.create_with_number(
+ team=other_team,
+ channel_source=Channel.WIDGET,
+ widget_session_id="other-sess",
+ distinct_id="other-user",
+ status=Status.NEW,
+ )
+ response = self.client.post(
+ self._bulk_url(),
+ {"ids": [str(self.tickets[0].id), str(other_ticket.id)], "action": "add", "tags": ["urgent"]},
+ format="json",
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ data = response.json()
+ self.assertEqual([row["id"] for row in data["updated"]], [str(self.tickets[0].id)])
+ self.assertEqual(data["skipped"], [{"id": str(other_ticket.id), "reason": "Not found"}])
+ self.assertEqual(self._ticket_tags(other_ticket), set())
+
+ def test_denied_ticket_skipped_with_permission_denied(self):
+ self.organization.available_product_features = [{"key": "access_control", "name": "Access control"}]
+ self.organization.save()
+ AccessControl.objects.create(
+ resource="ticket",
+ resource_id=str(self.tickets[0].id),
+ organization_member=self.user.organization_memberships.get(organization=self.organization),
+ team=self.team,
+ access_level="none",
+ )
+ ids = [str(t.id) for t in self.tickets]
+ response = self.client.post(
+ self._bulk_url(),
+ {"ids": ids, "action": "add", "tags": ["urgent"]},
+ format="json",
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ data = response.json()
+ self.assertEqual(data["skipped"], [{"id": str(self.tickets[0].id), "reason": "Permission denied"}])
+ self.assertEqual({row["id"] for row in data["updated"]}, {str(t.id) for t in self.tickets[1:]})
+ self.assertEqual(self._ticket_tags(self.tickets[0]), set())
+
+ def test_bulk_tags_mirror_activity_onto_ticket_timeline(self):
+ # Ticket-scope entries come from the TaggedItem mirror (RELATED_OBJECT_ACTIVITY_LOGGERS),
+ # so the bulk path must keep flowing through signal-firing TaggedItem writes — and exactly
+ # one entry per ticket per tag guards against the bulk endpoint double-logging.
+ ids = [str(t.id) for t in self.tickets[:2]]
+ self.client.post(
+ self._bulk_url(),
+ {"ids": ids, "action": "add", "tags": ["urgent"]},
+ format="json",
+ )
+ logs = ActivityLog.objects.filter(team_id=self.team.id, scope="Ticket", activity="updated")
+ self.assertEqual(logs.count(), 2)
+ self.assertEqual({log.item_id for log in logs}, set(ids))
+ for log in logs:
+ ticket = next(t for t in self.tickets if str(t.id) == log.item_id)
+ assert log.detail is not None
+ self.assertEqual(log.detail["name"], f"Ticket #{ticket.ticket_number}")
+ [change] = log.detail["changes"]
+ self.assertEqual(change["field"], "tag")
+ self.assertEqual(change["action"], "created")
+ self.assertEqual(change["after"], "urgent")
+
+
class TestTicketAssignment(APIBaseTest):
def setUp(self):
super().setUp()
diff --git a/products/conversations/backend/api/tickets.py b/products/conversations/backend/api/tickets.py
index ed0921ca5f7e..5f8da9b00604 100644
--- a/products/conversations/backend/api/tickets.py
+++ b/products/conversations/backend/api/tickets.py
@@ -36,7 +36,13 @@ from rest_framework.response import Response
from posthog.api.person import get_person_name
from posthog.api.routing import TeamAndOrgViewSetMixin
-from posthog.api.tagged_item import TaggedItemSerializerMixin, TaggedItemViewSetMixin, set_tags_on_object
+from posthog.api.tagged_item import (
+ BulkUpdateTagsUUIDRequestSerializer,
+ BulkUpdateTagsUUIDResponseSerializer,
+ TaggedItemSerializerMixin,
+ TaggedItemViewSetMixin,
+ set_tags_on_object,
+)
from posthog.dataclasses import frozen
from posthog.event_usage import report_user_action
from posthog.exceptions_capture import capture_exception
@@ -639,6 +645,11 @@ class _TicketUpdateDiff:
parameters=[TICKET_ID_PARAM], request=TicketUpdateRequestSerializer, responses=TicketSerializer
),
destroy=extend_schema(parameters=[TICKET_ID_PARAM]),
+ # The mixin action's default schema documents integer ids; tickets are keyed by UUID.
+ bulk_update_tags=extend_schema(
+ request=BulkUpdateTagsUUIDRequestSerializer,
+ responses={200: BulkUpdateTagsUUIDResponseSerializer},
+ ),
)
class TicketViewSet(TaggedItemViewSetMixin, TeamAndOrgViewSetMixin, AccessControlViewSetMixin, viewsets.ModelViewSet):
scope_object = "ticket"
@@ -660,6 +671,9 @@ class TicketViewSet(TaggedItemViewSetMixin, TeamAndOrgViewSetMixin, AccessContro
serializer_class = TicketSerializer
permission_classes = [IsAuthenticated, APIScopePermission]
pagination_class = TicketPagination
+ # ``bulk_tag_activity_scope`` stays unset: TaggedItem changes are already mirrored onto the
+ # ticket's activity stream (RELATED_OBJECT_ACTIVITY_LOGGERS), so a bulk entry would double-log.
+ bulk_update_tags_request_serializer_class = BulkUpdateTagsUUIDRequestSerializer
# Which search branch safely_get_queryset applied, for the latency histogram.
_search_path: str | None = None
diff --git a/products/conversations/frontend/generated/api.schemas.ts b/products/conversations/frontend/generated/api.schemas.ts
index 3a347ff101db..358579ef37b0 100644
--- a/products/conversations/frontend/generated/api.schemas.ts
+++ b/products/conversations/frontend/generated/api.schemas.ts
@@ -492,35 +492,48 @@ export const BulkUpdateTagsActionEnumApi = {
Set: 'set',
} as const
-export interface BulkUpdateTagsRequestApi {
+/**
+ * Variant of ``BulkUpdateTagsRequestSerializer`` for resources keyed by UUID (e.g. event definitions).
+ */
+export interface BulkUpdateTagsUUIDRequestApi {
/**
- * List of object IDs to update tags on.
+ * List of object UUIDs to update tags on.
* @maxItems 500
*/
- ids: number[]
+ ids: string[]
/** 'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.
*
* * `add` - add
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnumApi
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[]
}
-export interface BulkUpdateTagsItemApi {
- id: number
+export interface BulkUpdateTagsUUIDItemApi {
+ /** UUID of the object whose tags were updated. */
+ id: string
+ /** The object's full tag list after the update. */
tags: string[]
}
-export interface BulkUpdateTagsErrorApi {
- id: number
+export interface BulkUpdateTagsUUIDErrorApi {
+ /** UUID of the object that was skipped. */
+ id: string
+ /** Why the object was skipped, e.g. 'Not found'. */
reason: string
}
-export interface BulkUpdateTagsResponseApi {
- updated: BulkUpdateTagsItemApi[]
- skipped: BulkUpdateTagsErrorApi[]
+export interface BulkUpdateTagsUUIDResponseApi {
+ /** Objects whose tags were successfully updated. */
+ updated: BulkUpdateTagsUUIDItemApi[]
+ /** Objects that were skipped, with a reason each. */
+ skipped: BulkUpdateTagsUUIDErrorApi[]
}
export interface ComposeTicketApi {
diff --git a/products/conversations/frontend/generated/api.ts b/products/conversations/frontend/generated/api.ts
index 5786ce1e1f8b..b3fe3109f422 100644
--- a/products/conversations/frontend/generated/api.ts
+++ b/products/conversations/frontend/generated/api.ts
@@ -12,8 +12,8 @@ import type {
AiFeedbackRequestApi,
BulkUpdateStatusRequestApi,
BulkUpdateStatusResponseApi,
- BulkUpdateTagsRequestApi,
- BulkUpdateTagsResponseApi,
+ BulkUpdateTagsUUIDRequestApi,
+ BulkUpdateTagsUUIDResponseApi,
ComposeTicketApi,
ComposeTicketResponseApi,
ConversationsTicketsListParams,
@@ -363,14 +363,14 @@ export const getConversationsTicketsBulkUpdateTagsCreateUrl = (projectId: string
*/
export const conversationsTicketsBulkUpdateTagsCreate = async (
projectId: string,
- bulkUpdateTagsRequestApi: BulkUpdateTagsRequestApi,
+ bulkUpdateTagsUUIDRequestApi: BulkUpdateTagsUUIDRequestApi,
options?: RequestInit
-): Promise<BulkUpdateTagsResponseApi> => {
- return apiMutator<BulkUpdateTagsResponseApi>(getConversationsTicketsBulkUpdateTagsCreateUrl(projectId), {
+): Promise<BulkUpdateTagsUUIDResponseApi> => {
+ return apiMutator<BulkUpdateTagsUUIDResponseApi>(getConversationsTicketsBulkUpdateTagsCreateUrl(projectId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(bulkUpdateTagsRequestApi),
+ body: JSON.stringify(bulkUpdateTagsUUIDRequestApi),
})
}
diff --git a/products/conversations/frontend/generated/api.zod.ts b/products/conversations/frontend/generated/api.zod.ts
index 4973f9bacdc8..da47b2bea901 100644
--- a/products/conversations/frontend/generated/api.zod.ts
+++ b/products/conversations/frontend/generated/api.zod.ts
@@ -238,19 +238,28 @@ export const ConversationsTicketsBulkUpdateStatusCreateBody = /* @__PURE__ */ zo
*/
export const conversationsTicketsBulkUpdateTagsCreateBodyIdsMax = 500
-export const ConversationsTicketsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
- ids: zod
- .array(zod.number())
- .max(conversationsTicketsBulkUpdateTagsCreateBodyIdsMax)
- .describe('List of object IDs to update tags on.'),
- action: zod
- .enum(['add', 'remove', 'set'])
- .describe('\* `add` - add\n\* `remove` - remove\n\* `set` - set')
- .describe(
- "'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
- ),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
-})
+export const conversationsTicketsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const conversationsTicketsBulkUpdateTagsCreateBodyTagsMax = 100
+
+export const ConversationsTicketsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod
+ .object({
+ ids: zod
+ .array(zod.uuid())
+ .max(conversationsTicketsBulkUpdateTagsCreateBodyIdsMax)
+ .describe('List of object UUIDs to update tags on.'),
+ action: zod
+ .enum(['add', 'remove', 'set'])
+ .describe('\* `add` - add\n\* `remove` - remove\n\* `set` - set')
+ .describe(
+ "'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
+ ),
+ tags: zod
+ .array(zod.string().max(conversationsTicketsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(conversationsTicketsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
+ })
+ .describe('Variant of ``BulkUpdateTagsRequestSerializer`` for resources keyed by UUID (e.g. event definitions).')
/**
* Create a new outbound ticket and send the first message to the customer.
diff --git a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
index afbec162043a..f23602fecb76 100644
--- a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
+++ b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
@@ -17,6 +17,7 @@ import {
Tooltip,
} from '@posthog/lemon-ui'
+import { BulkUpdateTagsButton } from 'lib/components/BulkActions/BulkUpdateTagsButton'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { useBulkSelection } from 'lib/lemon-ui/LemonTable/useBulkSelection'
import { newInternalTab } from 'lib/utils/newInternalTab'
@@ -68,7 +69,7 @@ interface SupportTicketsTableProps {
function SupportTicketsBulkActions(): JSX.Element {
const { selectedTicketIds, selectedTickets, editableSelectedTicketIds, bulkUpdating } =
useValues(supportTicketsSceneLogic)
- const { bulkUpdateStatus } = useActions(supportTicketsSceneLogic)
+ const { bulkUpdateStatus, clearSelectedTickets, loadTickets } = useActions(supportTicketsSceneLogic)
const hasSelection = selectedTicketIds.length > 0
const editableTicketIds = editableSelectedTicketIds
@@ -81,34 +82,44 @@ function SupportTicketsBulkActions(): JSX.Element {
return acc === s ? acc : 'mixed'
}, null)
+ const noEditableSelectionReason = !hasSelection
+ ? 'Select tickets first'
+ : editableTicketIds.length === 0
+ ? "You don't have edit access to any of the selected tickets"
+ : undefined
+ const restrictedSelectionTooltip =
+ hasRestrictedSelection && editableTicketIds.length > 0
+ ? `${selectedTicketIds.length - editableTicketIds.length} selected ticket(s) will be skipped because you don't have edit access to them`
+ : undefined
+
return (
- <LemonSelect
- onChange={(value) => {
- if (!value || value === currentStatus || editableTicketIds.length === 0) {
- return
- }
- bulkUpdateStatus(editableTicketIds, value as TicketStatus)
- }}
- value={null}
- placeholder="Mark as"
- loading={bulkUpdating}
- disabledReason={
- !hasSelection
- ? 'Select tickets first'
- : bulkUpdating
- ? 'Updating…'
- : editableTicketIds.length === 0
- ? "You don't have edit access to any of the selected tickets"
- : undefined
- }
- tooltip={
- hasRestrictedSelection && editableTicketIds.length > 0
- ? `${selectedTicketIds.length - editableTicketIds.length} selected ticket(s) will be skipped because you don't have edit access to them`
- : undefined
- }
- options={statusOptionsWithoutAll.map((o) => ({ value: o.value, label: o.label }))}
- size="small"
- />
+ <>
+ <LemonSelect
+ onChange={(value) => {
+ if (!value || value === currentStatus || editableTicketIds.length === 0) {
+ return
+ }
+ bulkUpdateStatus(editableTicketIds, value as TicketStatus)
+ }}
+ value={null}
+ placeholder="Mark as"
+ loading={bulkUpdating}
+ disabledReason={bulkUpdating ? 'Updating…' : noEditableSelectionReason}
+ tooltip={restrictedSelectionTooltip}
+ options={statusOptionsWithoutAll.map((o) => ({ value: o.value, label: o.label }))}
+ size="small"
+ />
+ <BulkUpdateTagsButton
+ resource="conversations/tickets"
+ selectedIds={editableTicketIds}
+ disabledReason={noEditableSelectionReason}
+ tooltip={restrictedSelectionTooltip}
+ onSuccess={() => {
+ clearSelectedTickets()
+ loadTickets()
+ }}
+ />
+ </>
)
}
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index a3bc3c75b6ac..ad5240b6ab4e 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -10050,7 +10050,11 @@ export interface BulkUpdateTagsRequestApi {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnumApi
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[]
}
diff --git a/products/dashboards/frontend/generated/api.zod.ts b/products/dashboards/frontend/generated/api.zod.ts
index ea6bbb01280a..eb89dc663acd 100644
--- a/products/dashboards/frontend/generated/api.zod.ts
+++ b/products/dashboards/frontend/generated/api.zod.ts
@@ -3453,6 +3453,10 @@ export const DashboardsUpdateWidgetsBatchBody = /* @__PURE__ */ zod
*/
export const dashboardsBulkUpdateTagsCreateBodyIdsMax = 500
+export const dashboardsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const dashboardsBulkUpdateTagsCreateBodyTagsMax = 100
+
export const DashboardsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
ids: zod
.array(zod.number())
@@ -3464,7 +3468,10 @@ export const DashboardsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
.describe(
"'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
+ tags: zod
+ .array(zod.string().max(dashboardsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(dashboardsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
})
export const dashboardsCreateFromTemplateJsonCreateBodyNameMax = 400
diff --git a/products/event_definitions/frontend/generated/api.schemas.ts b/products/event_definitions/frontend/generated/api.schemas.ts
index 2efde4990b04..0aae74b8d3ab 100644
--- a/products/event_definitions/frontend/generated/api.schemas.ts
+++ b/products/event_definitions/frontend/generated/api.schemas.ts
@@ -197,7 +197,11 @@ export interface BulkUpdateTagsUUIDRequestApi {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnumApi
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[]
}
diff --git a/products/event_definitions/frontend/generated/api.zod.ts b/products/event_definitions/frontend/generated/api.zod.ts
index 8c46424e833a..088597de1c5a 100644
--- a/products/event_definitions/frontend/generated/api.zod.ts
+++ b/products/event_definitions/frontend/generated/api.zod.ts
@@ -102,6 +102,10 @@ export const EventDefinitionsPartialUpdateBody = /* @__PURE__ */ zod
*/
export const eventDefinitionsBulkUpdateTagsCreateBodyIdsMax = 500
+export const eventDefinitionsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const eventDefinitionsBulkUpdateTagsCreateBodyTagsMax = 100
+
export const EventDefinitionsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod
.object({
ids: zod
@@ -114,7 +118,10 @@ export const EventDefinitionsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod
.describe(
"'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
+ tags: zod
+ .array(zod.string().max(eventDefinitionsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(eventDefinitionsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
})
.describe('Variant of ``BulkUpdateTagsRequestSerializer`` for resources keyed by UUID (e.g. event definitions).')
diff --git a/products/feature_flags/frontend/generated/api.schemas.ts b/products/feature_flags/frontend/generated/api.schemas.ts
index 4960462989e4..1844e0e83ae0 100644
--- a/products/feature_flags/frontend/generated/api.schemas.ts
+++ b/products/feature_flags/frontend/generated/api.schemas.ts
@@ -1527,7 +1527,11 @@ export interface BulkUpdateTagsRequestApi {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnumApi
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[]
}
diff --git a/products/feature_flags/frontend/generated/api.zod.ts b/products/feature_flags/frontend/generated/api.zod.ts
index f9e81dd265ee..d4a30e07aad8 100644
--- a/products/feature_flags/frontend/generated/api.zod.ts
+++ b/products/feature_flags/frontend/generated/api.zod.ts
@@ -1196,6 +1196,10 @@ export const FeatureFlagsBulkKeysRetrieveBody = /* @__PURE__ */ zod.object({
*/
export const featureFlagsBulkUpdateTagsCreateBodyIdsMax = 500
+export const featureFlagsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const featureFlagsBulkUpdateTagsCreateBodyTagsMax = 100
+
export const FeatureFlagsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
ids: zod
.array(zod.number())
@@ -1207,7 +1211,10 @@ export const FeatureFlagsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
.describe(
"'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
+ tags: zod
+ .array(zod.string().max(featureFlagsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(featureFlagsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
})
/**
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 0eb63e4c03dd..6f866af7baa6 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -8754,7 +8754,11 @@ export interface BulkUpdateTagsRequestApi {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnumApi
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[]
}
diff --git a/products/product_analytics/frontend/generated/api.zod.ts b/products/product_analytics/frontend/generated/api.zod.ts
index b674febc8736..c86f54ae8cd1 100644
--- a/products/product_analytics/frontend/generated/api.zod.ts
+++ b/products/product_analytics/frontend/generated/api.zod.ts
@@ -297,6 +297,10 @@ export const InsightsBulkSetTestAccountFilterCreateBody = /* @__PURE__ */ zod.ob
*/
export const insightsBulkUpdateTagsCreateBodyIdsMax = 500
+export const insightsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const insightsBulkUpdateTagsCreateBodyTagsMax = 100
+
export const InsightsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
ids: zod
.array(zod.number())
@@ -308,7 +312,10 @@ export const InsightsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
.describe(
"'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
+ tags: zod
+ .array(zod.string().max(insightsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(insightsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
})
/**
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 19c227e6d7fa..88b548ede6b5 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -14821,7 +14821,11 @@ export namespace Schemas {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnum;
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[];
}
@@ -14859,7 +14863,11 @@ export namespace Schemas {
* * `remove` - remove
* * `set` - set */
action: BulkUpdateTagsActionEnum;
- /** Tag names to add, remove, or set. */
+ /**
+ * Tag names to add, remove, or set.
+ * @maxItems 100
+ * @items.maxLength 255
+ */
tags: string[];
}
diff --git a/services/mcp/src/generated/feature_flags/api.ts b/services/mcp/src/generated/feature_flags/api.ts
index f97424086302..84a4c9fe03e2 100644
--- a/services/mcp/src/generated/feature_flags/api.ts
+++ b/services/mcp/src/generated/feature_flags/api.ts
@@ -1168,6 +1168,10 @@ export const FeatureFlagsBulkUpdateTagsCreateParams = () => zod.object({
export const featureFlagsBulkUpdateTagsCreateBodyIdsMax = 500
+export const featureFlagsBulkUpdateTagsCreateBodyTagsItemMax = 255
+
+export const featureFlagsBulkUpdateTagsCreateBodyTagsMax = 100
+
export const FeatureFlagsBulkUpdateTagsCreateBody = () => zod.object({
ids: zod
.array(zod.number())
@@ -1179,7 +1183,10 @@ export const FeatureFlagsBulkUpdateTagsCreateBody = () => zod.object({
.describe(
"'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
),
- tags: zod.array(zod.string()).describe('Tag names to add, remove, or set.'),
+ tags: zod
+ .array(zod.string().max(featureFlagsBulkUpdateTagsCreateBodyTagsItemMax))
+ .max(featureFlagsBulkUpdateTagsCreateBodyTagsMax)
+ .describe('Tag names to add, remove, or set.'),
})
/**
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/feature-flags-bulk-update-tags-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/feature-flags-bulk-update-tags-create.json
index 8edf81559f24..54f52f08b1ce 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/feature-flags-bulk-update-tags-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/feature-flags-bulk-update-tags-create.json
@@ -17,8 +17,10 @@
"tags": {
"description": "Tag names to add, remove, or set.",
"items": {
+ "maxLength": 255,
"type": "string"
},
+ "maxItems": 100,
"type": "array"
}
},