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(error-tracking): set an assignee when creating external issues (#111762)

Hugues Pouillotcca6de5c46f6
diff --git a/posthog/api/integration.py b/posthog/api/integration.py
index f27fb4c1319b..d03ffe04387e 100644
--- a/posthog/api/integration.py
+++ b/posthog/api/integration.py
@@ -2,7 +2,7 @@ import os
import re
import json
import time
-from collections.abc import Iterable
+from collections.abc import Callable, Iterable
from typing import Any, NoReturn, Protocol, cast
from urllib.parse import urlencode
from uuid import uuid4
@@ -70,6 +70,8 @@ from posthog.models.integration import (
SLACK_INTEGRATION_KINDS,
AnthropicIntegration,
ApplePushIntegration,
+ Assignee,
+ AssigneeLookupFailed,
AWSRedshiftIntegration,
AWSRedshiftRoleBasedIntegration,
AWSS3Integration,
@@ -94,6 +96,7 @@ from posthog.models.integration import (
LinkedInAdsIntegration,
OauthIntegration,
PostgreSQLIntegration,
+ ReconnectRequired,
RedshiftIntegration,
S3CompatibleIntegration,
SlackIntegration,
@@ -408,6 +411,61 @@ class LinearTeamsResponseSerializer(serializers.Serializer):
teams = LinearTeamSerializer(many=True, help_text="Linear teams available to this integration.")
+class IntegrationAssigneeSerializer(serializers.Serializer):
+ id = serializers.CharField(
+ help_text=(
+ "Provider user identifier to pass as error tracking config.assignee: a Linear user ID, "
+ "a GitHub login, a GitLab user ID, or a Jira account ID."
+ )
+ )
+ name = serializers.CharField(help_text="User display name.")
+
+
+class IntegrationAssigneesResponseSerializer(serializers.Serializer):
+ users = IntegrationAssigneeSerializer(many=True, help_text="Users who can be assigned an issue, up to 100.")
+ reconnect_required = serializers.BooleanField(
+ help_text=(
+ "True when the connection lacks the permission to list users. Reconnecting the integration grants it."
+ ),
+ )
+
+
+class IntegrationAssigneesQuerySerializer(serializers.Serializer):
+ search = serializers.CharField(
+ required=False,
+ allow_blank=True,
+ default="",
+ help_text="Optional case-insensitive name search. Leave blank to list the first users.",
+ )
+
+
+class LinearTeamMembersQuerySerializer(IntegrationAssigneesQuerySerializer):
+ team_id = serializers.CharField(help_text="Linear team ID whose members to list.")
+
+
+class GitHubAssigneesQuerySerializer(IntegrationAssigneesQuerySerializer):
+ repository = serializers.CharField(
+ help_text="Repository name, or owner/name, whose assignable users to list.",
+ )
+
+
+class JiraAssignableUsersQuerySerializer(IntegrationAssigneesQuerySerializer):
+ project_key = serializers.CharField(help_text="Jira project key whose assignable users to list.")
+
+
+def assignees_response(lookup: Callable[[], list[Assignee]]) -> Response:
+ """Shape an assignee lookup as an `IntegrationAssigneesResponseSerializer` body."""
+ try:
+ assignees = lookup()
+ except ReconnectRequired:
+ return Response({"users": [], "reconnect_required": True})
+ except AssigneeLookupFailed as error:
+ raise ValidationError(str(error))
+ return Response(
+ {"users": [{"id": assignee.id, "name": assignee.name} for assignee in assignees], "reconnect_required": False}
+ )
+
+
class GitHubTeamSerializer(serializers.Serializer):
id = serializers.IntegerField(help_text="GitHub team numeric identifier.")
slug = serializers.CharField(help_text="GitHub team slug.")
@@ -1366,7 +1424,11 @@ class IntegrationViewSet(
"github_teams",
"github_available_installations",
"jira_projects",
+ "jira_assignable_users",
"linear_teams",
+ "linear_team_members",
+ "github_assignees",
+ "gitlab_members",
"anthropic_managed_agents",
"anthropic_managed_agent_environments",
"anthropic_managed_agent_vaults",
@@ -2054,6 +2116,21 @@ class IntegrationViewSet(
linear = LinearIntegration(instance)
return Response({"teams": linear.list_teams()})
+ @extend_schema(
+ parameters=[LinearTeamMembersQuerySerializer], responses={200: IntegrationAssigneesResponseSerializer}
+ )
+ @action(methods=["GET"], detail=True, url_path="linear_team_members")
+ def linear_team_members(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ query_serializer = LinearTeamMembersQuerySerializer(data=request.query_params)
+ query_serializer.is_valid(raise_exception=True)
+
+ instance = self.get_object()
+ if instance.kind != "linear":
+ raise ValidationError("linear_team_members endpoint is only supported for Linear integrations")
+ _ensure_oauth_token_valid(instance)
+ query = query_serializer.validated_data
+ return assignees_response(lambda: LinearIntegration(instance).list_assignees(query["team_id"], query["search"]))
+
@extend_schema(operation_id="integrations_anthropic_managed_agents_retrieve")
@action(methods=["GET"], detail=True, url_path="anthropic_managed_agents")
def anthropic_managed_agents(self, request: Request, *args: Any, **kwargs: Any) -> Response:
@@ -2180,6 +2257,20 @@ class IntegrationViewSet(
raise ValidationError("github_repos endpoint is only supported for GitHub integrations")
return Response(github_repos_page(GitHubIntegration(instance), query_serializer.validated_data))
+ @extend_schema(parameters=[GitHubAssigneesQuerySerializer], responses={200: IntegrationAssigneesResponseSerializer})
+ @action(methods=["GET"], detail=True, url_path="github_assignees")
+ def github_assignees(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ query_serializer = GitHubAssigneesQuerySerializer(data=request.query_params)
+ query_serializer.is_valid(raise_exception=True)
+
+ instance = self.get_object()
+ if instance.kind != "github":
+ raise ValidationError("github_assignees endpoint is only supported for GitHub integrations")
+ query = query_serializer.validated_data
+ return assignees_response(
+ lambda: GitHubIntegration(instance).list_assignees(query["repository"], query["search"])
+ )
+
@extend_schema(request=GitHubPrepareCallbackRequestSerializer, responses={204: None})
@action(methods=["POST"], detail=False, url_path="github/prepare_callback")
def github_prepare_callback(self, request: Request, *args: Any, **kwargs: Any) -> Response:
@@ -2430,6 +2521,37 @@ class IntegrationViewSet(
jira = JiraIntegration(instance)
return Response({"projects": jira.list_projects()})
+ @extend_schema(
+ parameters=[JiraAssignableUsersQuerySerializer], responses={200: IntegrationAssigneesResponseSerializer}
+ )
+ @action(methods=["GET"], detail=True, url_path="jira_assignable_users")
+ def jira_assignable_users(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ query_serializer = JiraAssignableUsersQuerySerializer(data=request.query_params)
+ query_serializer.is_valid(raise_exception=True)
+
+ instance = self.get_object()
+ if instance.kind != "jira":
+ raise ValidationError("jira_assignable_users endpoint is only supported for Jira integrations")
+ _ensure_oauth_token_valid(instance)
+ query = query_serializer.validated_data
+ return assignees_response(
+ lambda: JiraIntegration(instance).list_assignees(query["project_key"], query["search"])
+ )
+
+ @extend_schema(
+ parameters=[IntegrationAssigneesQuerySerializer], responses={200: IntegrationAssigneesResponseSerializer}
+ )
+ @action(methods=["GET"], detail=True, url_path="gitlab_members")
+ def gitlab_members(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ query_serializer = IntegrationAssigneesQuerySerializer(data=request.query_params)
+ query_serializer.is_valid(raise_exception=True)
+
+ instance = self.get_object()
+ if instance.kind != "gitlab":
+ raise ValidationError("gitlab_members endpoint is only supported for GitLab integrations")
+ search = query_serializer.validated_data["search"]
+ return assignees_response(lambda: GitLabIntegration(instance).list_assignees(search))
+
@action(methods=["POST"], detail=True, url_path="email/verify")
def email_verify(self, request, **kwargs):
email = EmailIntegration(self.get_object())
diff --git a/posthog/api/test/test_integration.py b/posthog/api/test/test_integration.py
index 307e83182867..7b91aa364e5f 100644
--- a/posthog/api/test/test_integration.py
+++ b/posthog/api/test/test_integration.py
@@ -54,12 +54,15 @@ from posthog.models.integration import (
PRIVATE_CHANNEL_WITHOUT_ACCESS,
SLACK_INTEGRATION_KINDS,
STRIPE_POSTHOG_SECRET_NAMES,
+ Assignee,
+ AssigneeLookupFailed,
EmailIntegration,
GitHubInstallationAccess,
GitHubIntegration,
GitHubIntegrationError,
GitHubUserAuthorization,
Integration,
+ ReconnectRequired,
SlackIntegration,
StripeIntegration,
github_account_type,
@@ -1720,6 +1723,10 @@ class TestIntegrationAPIKeyAccess:
("github_branches/?repo=org/repo", "get", "GitHub"),
("jira_projects/", "get", "Jira"),
("linear_teams/", "get", "Linear"),
+ ("linear_team_members/?team_id=team-id", "get", "Linear"),
+ ("github_assignees/?repository=repo", "get", "GitHub"),
+ ("gitlab_members/", "get", "GitLab"),
+ ("jira_assignable_users/?project_key=ENG", "get", "Jira"),
],
)
def test_provider_lookup_actions_on_wrong_integration_return_400(
@@ -2056,6 +2063,83 @@ class TestIntegrationAPIKeyAccess:
mock_ensure_token_valid.assert_called_once_with(linear_integration)
mock_list_teams.assert_called_once_with()
+ @pytest.mark.parametrize(
+ "kind,url_suffix,list_method,expected_call",
+ [
+ (
+ "linear",
+ "linear_team_members/?team_id=team-id&search=ad",
+ "LinearIntegration.list_assignees",
+ ("team-id", "ad"),
+ ),
+ (
+ "github",
+ "github_assignees/?repository=repo&search=ad",
+ "GitHubIntegration.list_assignees",
+ ("repo", "ad"),
+ ),
+ ("gitlab", "gitlab_members/?search=ad", "GitLabIntegration.list_assignees", ("ad",)),
+ (
+ "jira",
+ "jira_assignable_users/?project_key=ENG&search=ad",
+ "JiraIntegration.list_assignees",
+ ("ENG", "ad"),
+ ),
+ ],
+ )
+ @patch("posthog.api.integration._ensure_oauth_token_valid")
+ def test_assignee_lookups_with_read_scope_succeed(
+ self, _mock_ensure_token_valid, kind, url_suffix, list_method, expected_call, client: HttpClient
+ ):
+ integration = Integration.objects.create(team=self.team, kind=kind, config={}, sensitive_config={})
+ key_value = "test_key_assignees"
+ PersonalAPIKey.objects.create(
+ label="Test Key",
+ user=self.user,
+ secure_value=hash_key_value(key_value),
+ scopes=["integration:read"],
+ )
+
+ with patch(f"posthog.api.integration.{list_method}", return_value=[Assignee(id="u1", name="Ada")]) as mock_list:
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{integration.id}/{url_suffix}",
+ HTTP_AUTHORIZATION=f"Bearer {key_value}",
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json() == {"users": [{"id": "u1", "name": "Ada"}], "reconnect_required": False}
+ mock_list.assert_called_once_with(*expected_call)
+
+ @pytest.mark.parametrize(
+ "side_effect,expected_status,expected_body",
+ [
+ (ReconnectRequired(), status.HTTP_200_OK, {"users": [], "reconnect_required": True}),
+ (AssigneeLookupFailed("Could not list users"), status.HTTP_400_BAD_REQUEST, None),
+ ],
+ )
+ @patch("posthog.api.integration._ensure_oauth_token_valid")
+ def test_assignee_lookup_failures(
+ self, _mock_ensure_token_valid, side_effect, expected_status, expected_body, client: HttpClient
+ ):
+ integration = Integration.objects.create(team=self.team, kind="jira", config={}, sensitive_config={})
+ key_value = "test_key_jira_reconnect"
+ PersonalAPIKey.objects.create(
+ label="Test Key",
+ user=self.user,
+ secure_value=hash_key_value(key_value),
+ scopes=["integration:read"],
+ )
+
+ with patch("posthog.api.integration.JiraIntegration.list_assignees", side_effect=side_effect):
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{integration.id}/jira_assignable_users/?project_key=ENG",
+ HTTP_AUTHORIZATION=f"Bearer {key_value}",
+ )
+
+ assert response.status_code == expected_status
+ if expected_body is not None:
+ assert response.json() == expected_body
+
@patch("posthog.models.integration.github.GitHubIntegration.sync_repository_cache")
def test_refresh_github_repos_with_write_scope_succeeds(self, mock_sync_repository_cache, client: HttpClient):
mock_sync_repository_cache.return_value = [
diff --git a/posthog/models/github_integration_base.py b/posthog/models/github_integration_base.py
index 2b83c39e93cf..10e2ef7d0c3c 100644
--- a/posthog/models/github_integration_base.py
+++ b/posthog/models/github_integration_base.py
@@ -1421,6 +1421,8 @@ class GitHubIntegrationBase:
that must know whether one specific person lands checks here first.
"""
repo_path = repository if "/" in repository else f"{self.organization()}/{repository}"
+ if not _is_safe_github_repo_path(repo_path) or "/" in login or ".." in login:
+ return {"success": False, "error": "Unsafe repository or login for an assignee check"}
response = self._installation_authenticated_get(
f"https://api.github.com/repos/{repo_path}/assignees/{login}",
diff --git a/posthog/models/integration/__init__.py b/posthog/models/integration/__init__.py
index d0636ed91a35..89b6b633d166 100644
--- a/posthog/models/integration/__init__.py
+++ b/posthog/models/integration/__init__.py
@@ -15,6 +15,7 @@ from .anthropic import (
AnthropicIntegration,
AnthropicIntegrationError,
)
+from .assignees import Assignee, AssigneeLookupFailed, ReconnectRequired
from .aws import (
AWSCredentialsIntegration,
AWSRedshiftIntegration,
@@ -219,6 +220,9 @@ __all__ = [
"GitHubIntegration",
"GitHubIntegrationError",
"GitLabIntegrationError",
+ "Assignee",
+ "AssigneeLookupFailed",
+ "ReconnectRequired",
"GitLabIntegration",
"MetaGraphIntegration",
"MetaAdsIntegration",
diff --git a/posthog/models/integration/assignees.py b/posthog/models/integration/assignees.py
new file mode 100644
index 000000000000..94f35fe212f2
--- /dev/null
+++ b/posthog/models/integration/assignees.py
@@ -0,0 +1,20 @@
+"""People an integration can assign an external issue to, shared by the issue tracker integrations."""
+
+from posthog.dataclasses import frozen
+
+MAX_ASSIGNEES = 100
+
+
+@frozen
+class Assignee:
+ # Linear user ID, GitHub login, GitLab user ID, or Jira account ID: whatever the provider's create call takes.
+ id: str
+ name: str
+
+
+class AssigneeLookupFailed(Exception):
+ """The provider could not list assignable users."""
+
+
+class ReconnectRequired(Exception):
+ """The connection's grant predates a scope that the call needs, so only a reconnect fixes it."""
diff --git a/posthog/models/integration/github.py b/posthog/models/integration/github.py
index 99d50cdd1236..6eaf497be207 100644
--- a/posthog/models/integration/github.py
+++ b/posthog/models/integration/github.py
@@ -9,6 +9,7 @@ from datetime import datetime
from typing import Any
from django.conf import settings
+from django.core.cache import cache
import requests
import structlog
@@ -27,6 +28,7 @@ from posthog.plugins.plugin_server_api import reload_integrations_on_workers
from posthog.sync import database_sync_to_async
from . import common, model, refresh_tracking
+from .assignees import MAX_ASSIGNEES, Assignee, AssigneeLookupFailed
logger = structlog.get_logger(__name__)
@@ -37,6 +39,8 @@ _GITHUB_COMMIT_SHA_RE = re.compile(r"^[0-9a-fA-F]{7,40}$")
# GitHub's own login rule: alphanumerics and single hyphens, never leading or trailing. Keeps a
# crafted login out of the collaborator-permission URL path.
+GITHUB_ASSIGNEES_CACHE_TTL_SECONDS = 5 * 60
+
_GITHUB_LOGIN_RE = re.compile(r"^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$")
# Upper bound on the diff text we return, to keep a pathological diff (generated/vendored
@@ -409,11 +413,15 @@ class GitHubIntegration(GitHubIntegrationBase):
body: str = config.pop("body")
repository: str = config.pop("repository")
labels = config.pop("labels", None)
+ assignee = config.pop("assignee", None)
repo_path = repository if "/" in repository else f"{self.organization()}/{repository}"
json_body: dict[str, Any] = {"title": title, "body": body}
if labels:
json_body["labels"] = labels
+ if assignee:
+ # GitHub drops a login it cannot assign instead of failing, so the issue is still created.
+ json_body["assignees"] = [assignee]
response = self.api_request(
"POST",
@@ -430,6 +438,35 @@ class GitHubIntegration(GitHubIntegrationBase):
return {"number": issue["number"], "repository": repository}
+ def list_assignees(self, repository: str, search: str = "") -> list[Assignee]:
+ """Logins that can be assigned issues in ``repository``, matching ``search``.
+
+ GitHub cannot search assignees, so the full list is fetched once, cached briefly, and filtered here.
+ """
+ repo_path = repository if "/" in repository else f"{self.organization()}/{repository}"
+ if not _is_safe_github_repo_path(repo_path):
+ raise AssigneeLookupFailed(f"Unsafe GitHub repository path: {repo_path}")
+
+ cache_key = f"github_assignees:{self.integration.id}:{repo_path}"
+ logins: list[str] | None = cache.get(cache_key)
+ if logins is None:
+ responses, complete = self._installation_authenticated_get_pages(
+ f"https://api.github.com/repos/{repo_path}/assignees",
+ endpoint="/repos/{owner}/{repo}/assignees",
+ params={"per_page": 100},
+ )
+ pages = [response for response in responses if response.status_code == 200]
+ if not pages:
+ raise AssigneeLookupFailed(f"Could not list the assignable users in {repo_path}")
+ logins = [user["login"] for page in pages for user in page.json()]
+ # A partial list is still useful to show, but is not cached so the next search retries.
+ if complete:
+ cache.set(cache_key, logins, timeout=GITHUB_ASSIGNEES_CACHE_TTL_SECONDS)
+
+ needle = search.strip().lower()
+ matches = [login for login in logins if needle in login.lower()]
+ return [Assignee(id=login, name=login) for login in matches[:MAX_ASSIGNEES]]
+
def close_issue(self, repository: str, number: int, *, completed: bool = False) -> None:
"""Close an issue with the reason that matches the report outcome. Raises on failure."""
repo_path = repository if "/" in repository else f"{self.organization()}/{repository}"
diff --git a/posthog/models/integration/gitlab.py b/posthog/models/integration/gitlab.py
index 3d56f2e68eeb..e4fef7d0233a 100644
--- a/posthog/models/integration/gitlab.py
+++ b/posthog/models/integration/gitlab.py
@@ -2,13 +2,14 @@
import re
from typing import Any
-from urllib.parse import urlparse
+from urllib.parse import urlencode, urlparse
import requests
from posthog.security.url_validation import is_url_allowed
from . import common, model
+from .assignees import MAX_ASSIGNEES, Assignee, AssigneeLookupFailed
class GitLabIntegrationError(Exception):
@@ -89,23 +90,51 @@ class GitLabIntegration:
def hostname(self) -> str:
return common.dot_get(self.integration.config, "hostname")
+ def list_assignees(self, search: str = "") -> list[Assignee]:
+ """Active members of the connected project, including inherited ones, matching ``search``."""
+ hostname = self.integration.config.get("hostname")
+ project_id = self.integration.config.get("project_id")
+ access_token = self.integration.sensitive_config.get("access_token")
+
+ params: dict[str, str | int] = {"state": "active", "per_page": MAX_ASSIGNEES}
+ if search.strip():
+ params["query"] = search.strip()
+ query = urlencode(params)
+ # This endpoint answers with a JSON array, unlike the objects `get` is typed for.
+ members: object = GitLabIntegration.get(hostname, f"projects/{project_id}/members/all?{query}", access_token)
+ if not isinstance(members, list):
+ # GitLab reports failures as an object such as {"message": "403 Forbidden"}.
+ error = members.get("message") or members.get("error") if isinstance(members, dict) else None
+ raise AssigneeLookupFailed(f"Failed to list the GitLab project's members: {error or 'unexpected response'}")
+ # The state query filter only applies on paid GitLab tiers, so filter here as well.
+ return [
+ Assignee(id=str(member["id"]), name=member.get("name") or member["username"])
+ for member in members
+ if member.get("state", "active") == "active"
+ ]
+
def create_issue(self, config: dict[str, str]):
title: str = config.pop("title")
description: str = config.pop("body")
+ assignee = config.pop("assignee", None)
hostname = self.integration.config.get("hostname")
project_id = self.integration.config.get("project_id")
access_token = self.integration.sensitive_config.get("access_token")
+ payload: dict[str, Any] = {
+ "title": title,
+ "description": description,
+ "labels": "posthog",
+ }
+ if assignee:
+ payload["assignee_ids"] = [int(assignee)]
+
issue = GitLabIntegration.post(
hostname,
f"projects/{project_id}/issues",
access_token,
- {
- "title": title,
- "description": description,
- "labels": "posthog",
- },
+ payload,
)
return {"issue_id": issue["iid"]}
diff --git a/posthog/models/integration/jira.py b/posthog/models/integration/jira.py
index 534ddbda009f..83b89d4a2fd6 100644
--- a/posthog/models/integration/jira.py
+++ b/posthog/models/integration/jira.py
@@ -12,6 +12,7 @@ from rest_framework.exceptions import ValidationError
from posthog.exceptions_capture import capture_exception
from . import common, model, oauth
+from .assignees import MAX_ASSIGNEES, Assignee, AssigneeLookupFailed, ReconnectRequired
logger = structlog.get_logger(__name__)
@@ -157,6 +158,41 @@ class JiraIntegration:
projects = body.get("values", [])
return [{"id": p["id"], "key": p["key"], "name": p["name"]} for p in projects]
+ def list_assignees(self, project_key: str, search: str = "") -> list[Assignee]:
+ """Active users who can be assigned issues in the project, matching ``search``.
+
+ Raises ReconnectRequired for a connection made before PostHog requested read:jira-user.
+ """
+ cloud_id = self.cloud_id()
+ if not cloud_id:
+ raise AssigneeLookupFailed("Jira integration missing cloud_id")
+
+ self._ensure_token_valid()
+
+ response = requests.get(
+ f"https://api.atlassian.com/ex/jira/{cloud_id}/rest/api/3/user/assignable/search",
+ params={
+ "project": project_key,
+ "maxResults": str(MAX_ASSIGNEES),
+ **({"query": search.strip()} if search.strip() else {}),
+ },
+ headers={
+ "Authorization": f"Bearer {self.integration.sensitive_config['access_token']}",
+ "Accept": "application/json",
+ },
+ timeout=10,
+ )
+ # Jira answers 401 or 403 when the connection's grant lacks read:jira-user.
+ if response.status_code in (401, 403):
+ raise ReconnectRequired()
+ if response.status_code != 200:
+ raise AssigneeLookupFailed("Could not list the Jira project's assignable users")
+ return [
+ Assignee(id=user["accountId"], name=user.get("displayName") or user["accountId"])
+ for user in response.json()
+ if user.get("active", True)
+ ]
+
def create_issue(self, config: dict[str, str]) -> dict[str, str]:
"""Create a Jira issue and return the issue key"""
cloud_id = self.cloud_id()
@@ -168,15 +204,17 @@ class JiraIntegration:
title = config.get("title")
description = config.get("description")
project_key = config.get("project_key")
+ assignee = config.get("assignee")
- payload = {
- "fields": {
- "project": {"key": project_key},
- "summary": title,
- "description": description_to_adf(description or ""),
- "issuetype": {"name": "Task"},
- }
+ fields: dict[str, Any] = {
+ "project": {"key": project_key},
+ "summary": title,
+ "description": description_to_adf(description or ""),
+ "issuetype": {"name": "Task"},
}
+ if assignee:
+ fields["assignee"] = {"accountId": assignee}
+ payload = {"fields": fields}
response = requests.post(
f"https://api.atlassian.com/ex/jira/{cloud_id}/rest/api/3/issue",
diff --git a/posthog/models/integration/linear.py b/posthog/models/integration/linear.py
index a01a9818cc0a..e2c38a60549d 100644
--- a/posthog/models/integration/linear.py
+++ b/posthog/models/integration/linear.py
@@ -7,6 +7,7 @@ import structlog
from rest_framework.exceptions import ValidationError
from . import common, model
+from .assignees import MAX_ASSIGNEES, Assignee, AssigneeLookupFailed
logger = structlog.get_logger(__name__)
@@ -28,14 +29,40 @@ class LinearIntegration:
teams = common.dot_get(body, "data.teams.nodes")
return teams
+ def list_assignees(self, team_id: str, search: str = "") -> list[Assignee]:
+ """Active members of the team, filtered by name when ``search`` is set."""
+ search = search.strip()
+ user_filter = (
+ {"or": [{"name": {"containsIgnoreCase": search}}, {"displayName": {"containsIgnoreCase": search}}]}
+ if search
+ else None
+ )
+ body = self.query(
+ """
+ query TeamMembers($teamId: String!, $first: Int!, $filter: UserFilter) {
+ team(id: $teamId) { members(first: $first, filter: $filter) { nodes { id name displayName active } } }
+ }
+ """,
+ variables={"teamId": team_id, "first": MAX_ASSIGNEES, "filter": user_filter},
+ )
+ if body.get("errors"):
+ raise AssigneeLookupFailed("Failed to list the Linear team members")
+ members = common.dot_get(body, "data.team.members.nodes") or []
+ return [
+ Assignee(id=member["id"], name=member.get("displayName") or member["name"])
+ for member in members
+ if member.get("active", True)
+ ]
+
def create_issue(self, attachment_url: str, config: dict[str, str]) -> dict[str, str]:
title: str = config.pop("title")
description: str = config.pop("description")
linear_team_id = config.pop("team_id")
+ assignee_id = config.pop("assignee", None)
issue_create_query = """
- mutation IssueCreate($title: String!, $description: String!, $teamId: String!) {
- issueCreate(input: { title: $title, description: $description, teamId: $teamId }) {
+ mutation IssueCreate($title: String!, $description: String!, $teamId: String!, $assigneeId: String) {
+ issueCreate(input: { title: $title, description: $description, teamId: $teamId, assigneeId: $assigneeId }) {
success
issue { identifier }
}
@@ -43,7 +70,12 @@ class LinearIntegration:
"""
body = self.query(
issue_create_query,
- variables={"title": title, "description": description, "teamId": linear_team_id},
+ variables={
+ "title": title,
+ "description": description,
+ "teamId": linear_team_id,
+ "assigneeId": assignee_id or None,
+ },
)
linear_issue_id = common.dot_get(body, "data.issueCreate.issue.identifier")
# Linear reports failures in a 200 body; without this check a failed create would
diff --git a/posthog/models/integration/oauth.py b/posthog/models/integration/oauth.py
index 801eddc96eef..e72e8a488b8c 100644
--- a/posthog/models/integration/oauth.py
+++ b/posthog/models/integration/oauth.py
@@ -720,7 +720,7 @@ class OauthIntegration:
token_info_config_fields=[], # Handled specially in integration_from_oauth_response
client_id=settings.ATLASSIAN_APP_CLIENT_ID,
client_secret=settings.ATLASSIAN_APP_CLIENT_SECRET,
- scope="read:jira-work write:jira-work offline_access",
+ scope="read:jira-work write:jira-work read:jira-user offline_access",
id_path="cloud_id",
name_path="site_name",
)
diff --git a/posthog/models/test/integration/test_github.py b/posthog/models/test/integration/test_github.py
index 6749d3d19da3..1ae672af6933 100644
--- a/posthog/models/test/integration/test_github.py
+++ b/posthog/models/test/integration/test_github.py
@@ -1201,6 +1201,37 @@ class TestGitHubIntegrationModel(BaseTest):
assert result["success"] is False
assert result["status_code"] == 403
+ @parameterized.expand(
+ [
+ ("traversal_in_repository", "PostHog/posthog/../../orgs/PostHog/members", "alice"),
+ ("path_in_login", "PostHog/posthog", "alice/../../members"),
+ ]
+ )
+ def test_is_assignable_refuses_unsafe_paths_without_calling_github(self, _name: str, repository: str, login: str):
+ integration = self.create_integration(sensitive_config={"access_token": "ACCESS_TOKEN"})
+ github = GitHubIntegration(integration)
+ with patch.object(github, "_installation_authenticated_get") as mock_get:
+ result = github.is_assignable(repository, login)
+ assert result["success"] is False
+ mock_get.assert_not_called()
+
+ def test_list_assignees_searches_every_page_and_caches_the_list(self):
+ integration = self.create_integration(sensitive_config={"access_token": "ACCESS_TOKEN"})
+ github = GitHubIntegration(integration)
+ first = MagicMock(status_code=200)
+ first.json.return_value = [{"login": "alice"}, {"login": "bob"}]
+ second = MagicMock(status_code=200)
+ second.json.return_value = [{"login": "Alicia"}]
+ with patch.object(
+ github, "_installation_authenticated_get_pages", return_value=([first, second], True)
+ ) as mock_pages:
+ first_search = github.list_assignees("PostHog/posthog", "ali")
+ second_search = github.list_assignees("PostHog/posthog", "bob")
+
+ assert [assignee.id for assignee in first_search] == ["alice", "Alicia"]
+ assert [assignee.id for assignee in second_search] == ["bob"]
+ mock_pages.assert_called_once()
+
@parameterized.expand(
[
("every_page_read", True, {"success": True, "logins": ["alice", "bob"]}),
diff --git a/posthog/models/test/integration/test_gitlab.py b/posthog/models/test/integration/test_gitlab.py
index bb6f172e7475..a76d1426a2c1 100644
--- a/posthog/models/test/integration/test_gitlab.py
+++ b/posthog/models/test/integration/test_gitlab.py
@@ -121,3 +121,56 @@ class TestGitLabIntegrationModel:
assert mock_get.call_count == 2
assert mock_get.call_args.kwargs["params"]["search"] == "#42"
assert "iids[]" not in mock_get.call_args.kwargs["params"]
+
+ @patch("posthog.models.integration.gitlab.requests.post")
+ @patch("posthog.models.integration.gitlab.is_url_allowed", return_value=(True, None))
+ def test_create_issue_sends_assignee_as_numeric_id(self, _mock_is_url_allowed, mock_post):
+ from posthog.models.integration import GitLabIntegration
+
+ integration = MagicMock(
+ kind="gitlab",
+ config={"hostname": "https://gitlab.com", "project_id": 1},
+ sensitive_config={"access_token": "token123"},
+ )
+ mock_post.return_value.json.return_value = {"iid": 7}
+
+ GitLabIntegration(integration).create_issue({"title": "Checkout failed", "body": "Details", "assignee": "42"})
+
+ assert mock_post.call_args.kwargs["json"]["assignee_ids"] == [42]
+
+ @patch("posthog.models.integration.gitlab.requests.get")
+ @patch("posthog.models.integration.gitlab.is_url_allowed", return_value=(True, None))
+ def test_list_assignees_searches_and_skips_inactive_members(self, _mock_is_url_allowed, mock_get):
+ from posthog.models.integration import GitLabIntegration
+
+ integration = MagicMock(
+ kind="gitlab",
+ config={"hostname": "https://gitlab.com", "project_id": 1},
+ sensitive_config={"access_token": "token123"},
+ )
+ mock_get.return_value.json.return_value = [
+ {"id": 1, "username": "ada", "name": "Ada", "state": "active"},
+ {"id": 2, "username": "gone", "name": "Gone", "state": "blocked"},
+ ]
+
+ from posthog.models.integration import Assignee
+
+ assert GitLabIntegration(integration).list_assignees("ad") == [Assignee(id="1", name="Ada")]
+ assert mock_get.call_args.args[0] == (
+ "https://gitlab.com/api/v4/projects/1/members/all?state=active&per_page=100&query=ad"
+ )
+
+ @patch("posthog.models.integration.gitlab.requests.get")
+ @patch("posthog.models.integration.gitlab.is_url_allowed", return_value=(True, None))
+ def test_list_assignees_reports_the_gitlab_error(self, _mock_is_url_allowed, mock_get):
+ from posthog.models.integration import AssigneeLookupFailed, GitLabIntegration
+
+ integration = MagicMock(
+ kind="gitlab",
+ config={"hostname": "https://gitlab.com", "project_id": 1},
+ sensitive_config={"access_token": "token123"},
+ )
+ mock_get.return_value.json.return_value = {"message": "403 Forbidden"}
+
+ with pytest.raises(AssigneeLookupFailed, match="403 Forbidden"):
+ GitLabIntegration(integration).list_assignees()
diff --git a/posthog/models/test/integration/test_jira.py b/posthog/models/test/integration/test_jira.py
index e95553b78c52..f063fbc2346e 100644
--- a/posthog/models/test/integration/test_jira.py
+++ b/posthog/models/test/integration/test_jira.py
@@ -6,7 +6,7 @@ from unittest.mock import MagicMock, patch
from parameterized import parameterized
from rest_framework.exceptions import ValidationError
-from posthog.models.integration import Integration, JiraIntegration
+from posthog.models.integration import Assignee, Integration, JiraIntegration, ReconnectRequired
class TestJiraIntegrationModel:
@@ -146,3 +146,43 @@ class TestJiraIntegrationModel:
"version": 1,
"content": expected_content,
}
+
+ @parameterized.expand(
+ [
+ ("with_assignee", {"assignee": "account-id"}, {"accountId": "account-id"}),
+ ("without_assignee", {}, None),
+ ]
+ )
+ @patch("posthog.models.integration.jira.requests.post")
+ def test_create_issue_sets_assignee_by_account_id(self, _name, extra_config, expected_assignee, mock_post):
+ mock_post.return_value.status_code = 201
+ mock_post.return_value.json.return_value = {"key": "ENG-1", "id": "10001"}
+
+ JiraIntegration(self.integration()).create_issue(
+ {"project_key": "ENG", "title": "Checkout failed", "description": "Details", **extra_config}
+ )
+
+ assert mock_post.call_args.kwargs["json"]["fields"].get("assignee") == expected_assignee
+
+ @parameterized.expand([("unauthorized", 401), ("forbidden", 403)])
+ @patch("posthog.models.integration.jira.requests.get")
+ def test_list_assignees_requires_reconnect(self, _name, status_code, mock_get):
+ integration = self.integration()
+ integration.config = {"cloud_id": "cloud-id", "refreshed_at": 9999999999}
+ mock_get.return_value.status_code = status_code
+
+ with pytest.raises(ReconnectRequired):
+ JiraIntegration(integration).list_assignees("ENG")
+
+ @patch("posthog.models.integration.jira.requests.get")
+ def test_list_assignees_searches_and_skips_inactive_users(self, mock_get):
+ integration = self.integration()
+ integration.config = {"cloud_id": "cloud-id", "scope": "read:jira-work read:jira-user"}
+ mock_get.return_value.status_code = 200
+ mock_get.return_value.json.return_value = [
+ {"accountId": "a1", "displayName": "Ada", "active": True},
+ {"accountId": "a2", "displayName": "Gone", "active": False},
+ ]
+
+ assert JiraIntegration(integration).list_assignees("ENG", " ad ") == [Assignee(id="a1", name="Ada")]
+ assert mock_get.call_args.kwargs["params"] == {"project": "ENG", "maxResults": "100", "query": "ad"}
diff --git a/posthog/models/test/integration/test_linear.py b/posthog/models/test/integration/test_linear.py
index bedd445422d6..3c7a342887c8 100644
--- a/posthog/models/test/integration/test_linear.py
+++ b/posthog/models/test/integration/test_linear.py
@@ -6,7 +6,7 @@ from unittest.mock import patch
from parameterized import parameterized
from rest_framework.exceptions import ValidationError
-from posthog.models.integration import Integration, LinearIntegration
+from posthog.models.integration import Assignee, AssigneeLookupFailed, Integration, LinearIntegration
class TestLinearIntegrationModel(BaseTest):
@@ -112,8 +112,66 @@ class TestLinearIntegrationModel(BaseTest):
"title": 'Title "quoted"',
"description": "Description",
"teamId": 'team-id" } mutation {',
+ "assigneeId": None,
}
assert 'issue-id" } mutation {' not in attachment_query
assert attachment_variables["issueId"] == "LIN-123"
assert attachment_variables["title"] == "PostHog issue"
assert attachment_variables["url"].endswith(f'/project/{self.team.id}/error_tracking/issue-id" }} mutation {{')
+
+ def test_create_issue_sends_assignee_as_graphql_variable(self):
+ linear = LinearIntegration(self.create_integration())
+ with patch.object(
+ linear,
+ "query",
+ side_effect=[
+ {"data": {"issueCreate": {"issue": {"identifier": "LIN-123"}}}},
+ {"data": {"attachmentCreate": {"success": True}}},
+ ],
+ ) as mock_query:
+ linear.create_issue(
+ "https://us.posthog.com/error_tracking/issue-id",
+ {"team_id": "team-id", "title": "Title", "description": "Description", "assignee": "user-id"},
+ )
+
+ assert mock_query.call_args_list[0].kwargs["variables"]["assigneeId"] == "user-id"
+
+ @parameterized.expand(
+ [
+ ("blank_search_lists_members", " ", None),
+ (
+ "search_filters_by_name",
+ "ada",
+ {"or": [{"name": {"containsIgnoreCase": "ada"}}, {"displayName": {"containsIgnoreCase": "ada"}}]},
+ ),
+ ]
+ )
+ def test_list_assignees_skips_deactivated_users(self, _name, search, expected_filter):
+ linear = LinearIntegration(self.create_integration())
+ body = {
+ "data": {
+ "team": {
+ "members": {
+ "nodes": [
+ {"id": "u1", "name": "Ada Lovelace", "displayName": "ada", "active": True},
+ {"id": "u2", "name": "Gone User", "displayName": "gone", "active": False},
+ ]
+ }
+ }
+ }
+ }
+ with patch.object(linear, "query", return_value=body) as mock_query:
+ members = linear.list_assignees("team-id", search)
+
+ assert members == [Assignee(id="u1", name="ada")]
+ assert mock_query.call_args.kwargs["variables"] == {
+ "teamId": "team-id",
+ "first": 100,
+ "filter": expected_filter,
+ }
+
+ def test_list_assignees_raises_on_graphql_errors(self):
+ linear = LinearIntegration(self.create_integration())
+ with patch.object(linear, "query", return_value={"errors": [{"message": "forbidden"}]}):
+ with self.assertRaises(AssigneeLookupFailed):
+ linear.list_assignees("team-id")
diff --git a/products/error_tracking/backend/logic/external_references.py b/products/error_tracking/backend/logic/external_references.py
index 391e691a229b..4e0feed94f20 100644
--- a/products/error_tracking/backend/logic/external_references.py
+++ b/products/error_tracking/backend/logic/external_references.py
@@ -52,6 +52,23 @@ LINK_EXISTING_REQUIRED_CONTEXT_FIELDS: dict[str, dict[str, type]] = {
}
+def _validate_github_assignee(integration: Integration, repository: str, login: str) -> None:
+ # GitHub creates the issue and silently drops a login it cannot assign, so check before creating.
+ # Enterprise Managed User logins add an underscore and a shortcode, so allow "_" and a longer login.
+ if not re.fullmatch(r"[A-Za-z0-9_-]{1,100}", login):
+ raise ErrorTrackingExternalReferenceValidationError("GitHub assignee must be a GitHub login.")
+ result = GitHubIntegration(integration).is_assignable(repository.strip(), login)
+ if not result.get("success"):
+ raise ErrorTrackingExternalReferenceValidationError(
+ f"Could not check whether {login} can be assigned issues in {repository.strip()}. "
+ "Try again, or create the issue without an assignee."
+ )
+ if not result.get("assignable"):
+ raise ErrorTrackingExternalReferenceValidationError(
+ f"GitHub user {login} cannot be assigned issues in {repository.strip()}."
+ )
+
+
def _validate_external_reference_config(integration: Integration, config: Any) -> None:
if not isinstance(config, dict):
raise ErrorTrackingExternalReferenceValidationError("External reference config must be an object.")
@@ -80,6 +97,22 @@ def _validate_external_reference_config(integration: Integration, config: Any) -
f"Config fields for {integration.kind} cannot be blank: {', '.join(blank_fields)}."
)
+ assignee = config.get("assignee")
+ if assignee is not None and not isinstance(assignee, str):
+ raise ErrorTrackingExternalReferenceValidationError(
+ f"Config field assignee for {integration.kind} must be a string."
+ )
+ if (
+ assignee
+ and assignee.strip()
+ and integration.kind == Integration.IntegrationKind.GITLAB
+ and not re.fullmatch(r"[0-9]{1,20}", assignee.strip())
+ ):
+ raise ErrorTrackingExternalReferenceValidationError("GitLab assignee must be a numeric user ID.")
+
+ if assignee and assignee.strip() and integration.kind == Integration.IntegrationKind.GITHUB:
+ _validate_github_assignee(integration, config["repository"], assignee.strip())
+
if integration.kind == Integration.IntegrationKind.LINEAR:
team_id = config["team_id"]
teams = LinearIntegration(integration).list_teams() or []
@@ -229,6 +262,9 @@ def create_external_reference(
provider_config = dict(config or {})
title = provider_config["title"].strip()
provider_config["title"] = title
+ assignee = (provider_config.pop("assignee", None) or "").strip()
+ if assignee:
+ provider_config["assignee"] = assignee
if integration.kind == Integration.IntegrationKind.GITHUB:
created_context = GitHubIntegration(integration).create_issue(provider_config)
diff --git a/products/error_tracking/backend/presentation/views/external_references.py b/products/error_tracking/backend/presentation/views/external_references.py
index aa32c3d8352c..8796d3269f3c 100644
--- a/products/error_tracking/backend/presentation/views/external_references.py
+++ b/products/error_tracking/backend/presentation/views/external_references.py
@@ -89,7 +89,9 @@ class ErrorTrackingExternalReferenceSerializer(ErrorTrackingExternalReferenceRes
"linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: "
'github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; '
'linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; '
- 'jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}.'
+ 'jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. '
+ "Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, "
+ "or a Jira account ID."
),
)
issue = serializers.UUIDField(write_only=True, help_text="ID of the error tracking issue to link the reference to.")
diff --git a/products/error_tracking/backend/test/test_facade_api.py b/products/error_tracking/backend/test/test_facade_api.py
index 6bb21151e8fd..e41e9d4e7d1f 100644
--- a/products/error_tracking/backend/test/test_facade_api.py
+++ b/products/error_tracking/backend/test/test_facade_api.py
@@ -315,6 +315,106 @@ class TestErrorTrackingFacadeAPI(BaseTest):
distinct_id=self.user.id,
)
+ @parameterized.expand(
+ [
+ ("padded_id_is_trimmed", " 42 ", "42"),
+ ("blank_is_dropped", " ", None),
+ ]
+ )
+ @patch("products.error_tracking.backend.logic.external_references.GitLabIntegration.create_issue")
+ def test_create_external_reference_normalizes_assignee(self, _name, assignee, expected_assignee, mock_create_issue):
+ mock_create_issue.return_value = {"issue_id": 7}
+ issue = self._create_issue(team=self.team, name="Checkout TypeError")
+ integration = Integration.objects.create(
+ team=self.team,
+ kind=Integration.IntegrationKind.GITLAB.value,
+ config={"hostname": "https://gitlab.example.com", "project_id": 1},
+ sensitive_config={"access_token": "access-token"},
+ )
+
+ api.create_external_reference(
+ team_id=self.team.id,
+ issue_id=issue.id,
+ integration_id=integration.id,
+ config={"title": "Checkout TypeError", "body": "", "assignee": assignee},
+ distinct_id=self.user.id,
+ )
+
+ assert mock_create_issue.call_args.args[0].get("assignee") == expected_assignee
+
+ @parameterized.expand(
+ [
+ ("username_instead_of_id", "alice"),
+ ("non_string", 42),
+ ("non_ascii_digit", "\u00b2"),
+ ("too_long", "9" * 5000),
+ ]
+ )
+ @patch("products.error_tracking.backend.logic.external_references.GitLabIntegration.create_issue")
+ def test_create_external_reference_rejects_invalid_gitlab_assignee(self, _name, assignee, mock_create_issue):
+ issue = self._create_issue(team=self.team, name="Checkout TypeError")
+ integration = Integration.objects.create(
+ team=self.team,
+ kind=Integration.IntegrationKind.GITLAB.value,
+ config={"hostname": "https://gitlab.example.com", "project_id": 1},
+ sensitive_config={"access_token": "access-token"},
+ )
+
+ with self.assertRaises(api.ExternalReferenceValidationError):
+ api.create_external_reference(
+ team_id=self.team.id,
+ issue_id=issue.id,
+ integration_id=integration.id,
+ config={"title": "Checkout TypeError", "body": "", "assignee": assignee},
+ distinct_id=self.user.id,
+ )
+ mock_create_issue.assert_not_called()
+
+ @parameterized.expand(
+ [
+ ("not_assignable", "octocat", {"success": True, "assignable": False}, False),
+ ("assignable", "octocat", {"success": True, "assignable": True}, True),
+ ("managed_user_login", "mona_octo", {"success": True, "assignable": True}, True),
+ ("check_failed", "octocat", {"success": False, "error": "network"}, False),
+ ]
+ )
+ @patch("products.error_tracking.backend.logic.external_references.GitHubIntegration.create_issue")
+ @patch("products.error_tracking.backend.logic.external_references.GitHubIntegration.is_assignable")
+ def test_create_external_reference_checks_github_assignee(
+ self, _name, login, assignable_result, creates_issue, mock_is_assignable, mock_create_issue
+ ):
+ mock_is_assignable.return_value = assignable_result
+ mock_create_issue.return_value = {"number": 7, "repository": "posthog"}
+ issue = self._create_issue(team=self.team, name="Checkout TypeError")
+ integration = Integration.objects.create(
+ team=self.team,
+ kind=Integration.IntegrationKind.GITHUB.value,
+ config={"account": {"name": "acme"}},
+ sensitive_config={"access_token": "access-token"},
+ )
+ config = {"repository": "posthog", "title": "Checkout TypeError", "body": "", "assignee": login}
+
+ if creates_issue:
+ api.create_external_reference(
+ team_id=self.team.id,
+ issue_id=issue.id,
+ integration_id=integration.id,
+ config=config,
+ distinct_id=self.user.id,
+ )
+ else:
+ with self.assertRaises(api.ExternalReferenceValidationError):
+ api.create_external_reference(
+ team_id=self.team.id,
+ issue_id=issue.id,
+ integration_id=integration.id,
+ config=config,
+ distinct_id=self.user.id,
+ )
+
+ mock_is_assignable.assert_called_once_with("posthog", login)
+ assert mock_create_issue.called is creates_issue
+
def test_search_external_issues_requires_repository_for_github(self):
integration = Integration.objects.create(
team=self.team,
diff --git a/products/error_tracking/frontend/components/ExternalIssueAssigneeField.tsx b/products/error_tracking/frontend/components/ExternalIssueAssigneeField.tsx
new file mode 100644
index 000000000000..8b36832f5e6c
--- /dev/null
+++ b/products/error_tracking/frontend/components/ExternalIssueAssigneeField.tsx
@@ -0,0 +1,98 @@
+import { BuiltLogic, useActions, useValues } from 'kea'
+import { FormContext } from 'kea-forms'
+import { useContext, useEffect } from 'react'
+
+import { LemonInputSelect } from '@posthog/lemon-ui'
+
+import api from 'lib/api'
+import { useIntegrationManagementRestriction } from 'lib/integrations/integrationPermissions'
+import { LemonField } from 'lib/lemon-ui/LemonField'
+import { Link } from 'lib/lemon-ui/Link'
+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
+
+import { ExternalIssueAssigneeKind, externalIssueAssigneesLogic } from './externalIssueAssigneesLogic'
+
+// The form field holding the team, repository, or project that decides who can be assigned.
+const SCOPE_FIELDS: Record<ExternalIssueAssigneeKind, { field: string; placeholder: string } | null> = {
+ linear: { field: 'teamIds', placeholder: 'Choose a team first' },
+ github: { field: 'repositories', placeholder: 'Choose a repository first' },
+ jira: { field: 'projectKeys', placeholder: 'Choose a project first' },
+ gitlab: null,
+}
+
+export function ExternalIssueAssigneeField({
+ integrationId,
+ kind,
+}: {
+ integrationId: number
+ kind: ExternalIssueAssigneeKind
+}): JSX.Element {
+ const { logic: formLogic, formKey } = useContext(FormContext)
+ const formValues: Record<string, any> = useValues(formLogic as BuiltLogic)[formKey] ?? {}
+ const scopeField = SCOPE_FIELDS[kind]
+ const scope: string | null = scopeField ? (formValues[scopeField.field]?.[0] ?? null) : null
+
+ const assigneesLogic = externalIssueAssigneesLogic({ integrationId, kind, scope })
+ const { assignees, assigneesLoading, knownUserNames } = useValues(assigneesLogic)
+ const { setSearch } = useActions(assigneesLogic)
+ const { reportIntegrationConnectClicked } = useActions(eventUsageLogic)
+ const restrictedReason = useIntegrationManagementRestriction()
+
+ // Someone assignable in one team or repository may not be assignable in the next one.
+ useEffect(() => {
+ ;(formLogic as BuiltLogic).actions.setFormValue('assignees', [])
+ }, [formLogic, scope])
+
+ const reconnectRequired = !!assignees?.reconnect_required
+ const selectedId: string | undefined = formValues.assignees?.[0]
+ const options = (assignees?.users ?? []).map((user) => ({ key: user.id, label: user.name }))
+ if (selectedId && !options.some((option) => option.key === selectedId) && knownUserNames[selectedId]) {
+ options.unshift({ key: selectedId, label: knownUserNames[selectedId] })
+ }
+ const placeholder =
+ scopeField && !scope
+ ? scopeField.placeholder
+ : reconnectRequired
+ ? 'Reconnect to choose an assignee'
+ : !assigneesLoading && assignees === null
+ ? "Couldn't load users"
+ : 'Unassigned'
+
+ return (
+ <LemonField
+ name="assignees"
+ label="Assignee"
+ showOptional
+ help={
+ reconnectRequired ? (
+ restrictedReason ? (
+ 'Ask a project admin to reconnect this integration so it can list users.'
+ ) : (
+ <>
+ This connection can't list users.{' '}
+ <Link
+ to={api.integrations.authorizeUrl({ kind, next: window.location.pathname })}
+ disableClientSideRouting
+ onClick={() => reportIntegrationConnectClicked(kind, kind, 'missing_scopes_reconnect')}
+ >
+ Reconnect
+ </Link>{' '}
+ to grant access.
+ </>
+ )
+ ) : undefined
+ }
+ >
+ <LemonInputSelect
+ mode="single"
+ data-attr="external-issue-assignee"
+ placeholder={placeholder}
+ options={options}
+ onInputChange={setSearch}
+ disableFiltering
+ loading={assigneesLoading}
+ disabled={(!!scopeField && !scope) || reconnectRequired}
+ />
+ </LemonField>
+ )
+}
diff --git a/products/error_tracking/frontend/components/ExternalReferences.tsx b/products/error_tracking/frontend/components/ExternalReferences.tsx
index 49eb49241f4b..6fb55c44a724 100644
--- a/products/error_tracking/frontend/components/ExternalReferences.tsx
+++ b/products/error_tracking/frontend/components/ExternalReferences.tsx
@@ -36,6 +36,7 @@ import {
errorTrackingIssueSceneLogic,
errorTrackingIssueSceneLogicType,
} from '../scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic'
+import { ExternalIssueAssigneeField } from './ExternalIssueAssigneeField'
import { appendStacktrace, getStacktrace } from './externalIssueBody'
import { externalIssueSearchLogic } from './externalIssueSearchLogic'
import { IncludeStacktraceField } from './IncludeStacktraceField'
@@ -262,6 +263,11 @@ function getSubmittedBody(
)
}
+function withAssignee(config: Record<string, string>, assignees: string[] | undefined): Record<string, string> {
+ const assignee = assignees?.[0]
+ return assignee ? { ...config, assignee } : config
+}
+
function createGitHubIssueForm(
issue: ErrorTrackingRelationalIssue,
issueUrl: string,
@@ -279,10 +285,12 @@ function createGitHubIssueForm(
includeStacktrace: true,
integrationId: integration.id,
repositories: [],
+ assignees: [],
},
content: (
<div className="flex flex-col gap-y-2">
<GitHubRepositorySelectField integrationId={integration.id} />
+ <ExternalIssueAssigneeField integrationId={integration.id} kind="github" />
<LemonField name="title" label="Title">
<LemonInput data-attr="issue-title" placeholder="Issue title" size="small" />
</LemonField>
@@ -297,11 +305,11 @@ function createGitHubIssueForm(
repositories: (repositories) =>
repositories && repositories.length === 0 ? 'You must choose a repository' : undefined,
},
- onSubmit: ({ title, body, includeStacktrace, repositories }) => {
+ onSubmit: ({ title, body, includeStacktrace, repositories, assignees }) => {
const submittedBody = getSubmittedBody(sceneLogic, body, includeStacktrace)
onSubmit(
integration.id,
- { repository: repositories[0], title, body: submittedBody },
+ withAssignee({ repository: repositories[0], title, body: submittedBody }, assignees),
submittedBody !== body
)
},
@@ -324,9 +332,11 @@ function createGitLabIssueForm(
body: `**PostHog issue:** ${issueUrl}`,
includeStacktrace: true,
integrationId: integration.id,
+ assignees: [],
},
content: (
<div className="flex flex-col gap-y-2">
+ <ExternalIssueAssigneeField integrationId={integration.id} kind="gitlab" />
<LemonField name="title" label="Title">
<LemonInput data-attr="issue-title" placeholder="Issue title" size="small" />
</LemonField>
@@ -339,9 +349,9 @@ function createGitLabIssueForm(
errors: {
title: (title) => (!title ? 'You must enter a title' : undefined),
},
- onSubmit: ({ title, body, includeStacktrace }) => {
+ onSubmit: ({ title, body, includeStacktrace, assignees }) => {
const submittedBody = getSubmittedBody(sceneLogic, body, includeStacktrace)
- onSubmit(integration.id, { title, body: submittedBody }, submittedBody !== body)
+ onSubmit(integration.id, withAssignee({ title, body: submittedBody }, assignees), submittedBody !== body)
},
})
}
@@ -363,10 +373,12 @@ function createLinearIssueForm(
includeStacktrace: true,
integrationId: integration.id,
teamIds: [],
+ assignees: [],
},
content: (
<div className="flex flex-col gap-y-2">
<LinearTeamSelectField integrationId={integration.id} />
+ <ExternalIssueAssigneeField integrationId={integration.id} kind="linear" />
<LemonField name="title" label="Title">
<LemonInput data-attr="issue-title" placeholder="Issue title" size="small" />
</LemonField>
@@ -380,11 +392,11 @@ function createLinearIssueForm(
title: (title) => (!title ? 'You must enter a title' : undefined),
teamIds: (teamIds) => (teamIds && teamIds.length === 0 ? 'You must choose a team' : undefined),
},
- onSubmit: ({ title, description, includeStacktrace, teamIds }) => {
+ onSubmit: ({ title, description, includeStacktrace, teamIds, assignees }) => {
const submittedDescription = getSubmittedBody(sceneLogic, description, includeStacktrace)
onSubmit(
integration.id,
- { team_id: teamIds[0], title, description: submittedDescription },
+ withAssignee({ team_id: teamIds[0], title, description: submittedDescription }, assignees),
submittedDescription !== description
)
},
@@ -408,10 +420,12 @@ function createJiraIssueForm(
includeStacktrace: true,
integrationId: integration.id,
projectKeys: [],
+ assignees: [],
},
content: (
<div className="flex flex-col gap-y-2">
<JiraProjectSelectField integrationId={integration.id} />
+ <ExternalIssueAssigneeField integrationId={integration.id} kind="jira" />
<LemonField name="title" label="Summary">
<LemonInput data-attr="jira-issue-title" placeholder="Issue summary" size="small" />
</LemonField>
@@ -426,11 +440,11 @@ function createJiraIssueForm(
projectKeys: (projectKeys) =>
projectKeys && projectKeys.length === 0 ? 'You must choose a project' : undefined,
},
- onSubmit: ({ title, description, includeStacktrace, projectKeys }) => {
+ onSubmit: ({ title, description, includeStacktrace, projectKeys, assignees }) => {
const submittedDescription = getSubmittedBody(sceneLogic, description, includeStacktrace)
onSubmit(
integration.id,
- { project_key: projectKeys[0], title, description: submittedDescription },
+ withAssignee({ project_key: projectKeys[0], title, description: submittedDescription }, assignees),
submittedDescription !== description
)
},
diff --git a/products/error_tracking/frontend/components/externalIssueAssigneesLogic.test.ts b/products/error_tracking/frontend/components/externalIssueAssigneesLogic.test.ts
new file mode 100644
index 000000000000..1584f55f89c8
--- /dev/null
+++ b/products/error_tracking/frontend/components/externalIssueAssigneesLogic.test.ts
@@ -0,0 +1,110 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { initKeaTests } from '~/test/init'
+
+import {
+ integrationsGithubAssigneesRetrieve,
+ integrationsGitlabMembersRetrieve,
+ integrationsJiraAssignableUsersRetrieve,
+ integrationsLinearTeamMembersRetrieve,
+} from 'products/integrations/frontend/generated/api'
+
+import { ExternalIssueAssigneeKind, externalIssueAssigneesLogic } from './externalIssueAssigneesLogic'
+
+jest.mock('products/integrations/frontend/generated/api', () => ({
+ integrationsGithubAssigneesRetrieve: jest.fn(),
+ integrationsGitlabMembersRetrieve: jest.fn(),
+ integrationsJiraAssignableUsersRetrieve: jest.fn(),
+ integrationsLinearTeamMembersRetrieve: jest.fn(),
+}))
+
+const USERS = [{ id: 'u1', name: 'Ada' }]
+
+const PROVIDER_CALLS: Record<ExternalIssueAssigneeKind, jest.Mock> = {
+ linear: jest.mocked(integrationsLinearTeamMembersRetrieve),
+ github: jest.mocked(integrationsGithubAssigneesRetrieve),
+ gitlab: jest.mocked(integrationsGitlabMembersRetrieve),
+ jira: jest.mocked(integrationsJiraAssignableUsersRetrieve),
+}
+
+describe('externalIssueAssigneesLogic', () => {
+ let logic: ReturnType<typeof externalIssueAssigneesLogic.build>
+
+ beforeEach(() => {
+ initKeaTests()
+ Object.values(PROVIDER_CALLS).forEach((call) => call.mockReset().mockResolvedValue({ users: USERS }))
+ })
+
+ afterEach(() => logic?.unmount())
+
+ test.each([
+ ['linear', 'team-id', { team_id: 'team-id', search: '' }],
+ ['github', 'posthog', { repository: 'posthog', search: '' }],
+ ['jira', 'ENG', { project_key: 'ENG', search: '' }],
+ ] as const)('%s sends the chosen scope as its lookup parameter', async (kind, scope, params) => {
+ logic = externalIssueAssigneesLogic({ integrationId: 1, kind, scope })
+ logic.mount()
+
+ await expectLogic(logic)
+ .toDispatchActions(['loadAssigneesSuccess'])
+ .toMatchValues({
+ assignees: { users: USERS },
+ })
+ expect(PROVIDER_CALLS[kind]).toHaveBeenCalledWith(expect.any(String), 1, params)
+ })
+
+ test.each(['linear', 'github', 'jira'] as const)('%s waits for a scope before calling the API', async (kind) => {
+ logic = externalIssueAssigneesLogic({ integrationId: 1, kind, scope: null })
+ logic.mount()
+
+ await expectLogic(logic)
+ .toDispatchActions(['loadAssigneesSuccess'])
+ .toMatchValues({
+ assignees: { users: [], reconnect_required: false },
+ })
+ expect(PROVIDER_CALLS[kind]).not.toHaveBeenCalled()
+ })
+
+ it('keeps the reconnect flag so the field can ask for a reconnect', async () => {
+ PROVIDER_CALLS.jira.mockResolvedValue({ users: [], reconnect_required: true })
+ logic = externalIssueAssigneesLogic({ integrationId: 1, kind: 'jira', scope: 'ENG' })
+ logic.mount()
+
+ await expectLogic(logic)
+ .toDispatchActions(['loadAssigneesSuccess'])
+ .toMatchValues({
+ assignees: { users: [], reconnect_required: true },
+ })
+ })
+
+ it('searches once the user stops typing, with the latest input', async () => {
+ jest.useFakeTimers()
+ try {
+ logic = externalIssueAssigneesLogic({ integrationId: 1, kind: 'gitlab', scope: null })
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadAssigneesSuccess'])
+ PROVIDER_CALLS.gitlab.mockClear()
+
+ logic.actions.setSearch('a')
+ logic.actions.setSearch('ad')
+ jest.advanceTimersByTime(300)
+
+ await expectLogic(logic).toDispatchActions(['loadAssigneesSuccess'])
+ expect(PROVIDER_CALLS.gitlab).toHaveBeenCalledTimes(1)
+ expect(PROVIDER_CALLS.gitlab).toHaveBeenCalledWith(expect.any(String), 1, { search: 'ad' })
+ } finally {
+ jest.useRealTimers()
+ }
+ })
+
+ it('leaves assignees unresolved when the lookup fails', async () => {
+ PROVIDER_CALLS.gitlab.mockRejectedValue(new Error('boom'))
+ logic = externalIssueAssigneesLogic({ integrationId: 1, kind: 'gitlab', scope: null })
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadAssigneesFailure']).toMatchValues({
+ assignees: null,
+ assigneesLoading: false,
+ })
+ })
+})
diff --git a/products/error_tracking/frontend/components/externalIssueAssigneesLogic.ts b/products/error_tracking/frontend/components/externalIssueAssigneesLogic.ts
new file mode 100644
index 000000000000..941a400657c6
--- /dev/null
+++ b/products/error_tracking/frontend/components/externalIssueAssigneesLogic.ts
@@ -0,0 +1,133 @@
+import { LogicWrapper, MakeLogicType, actions, afterMount, kea, key, listeners, path, props, reducers } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import {
+ integrationsGithubAssigneesRetrieve,
+ integrationsGitlabMembersRetrieve,
+ integrationsJiraAssignableUsersRetrieve,
+ integrationsLinearTeamMembersRetrieve,
+} from 'products/integrations/frontend/generated/api'
+import type { IntegrationAssigneesResponseApi } from 'products/integrations/frontend/generated/api.schemas'
+
+export type ExternalIssueAssigneeKind = 'linear' | 'github' | 'gitlab' | 'jira'
+
+export interface ExternalIssueAssigneesLogicProps {
+ integrationId: number
+ kind: ExternalIssueAssigneeKind
+ /** The Linear team, GitHub repository, or Jira project the issue is created in. GitLab needs none. */
+ scope: string | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface externalIssueAssigneesLogicValues {
+ assignees: IntegrationAssigneesResponseApi | null
+ assigneesLoading: boolean
+ knownUserNames: Record<string, string>
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface externalIssueAssigneesLogicActions {
+ loadAssignees: (search: string) => string
+ loadAssigneesFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadAssigneesSuccess: (
+ assignees: IntegrationAssigneesResponseApi,
+ payload?: string
+ ) => {
+ assignees: IntegrationAssigneesResponseApi
+ payload?: string
+ }
+ setSearch: (search: string) => {
+ search: string
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface externalIssueAssigneesLogicMeta {
+ key: string
+}
+
+export type externalIssueAssigneesLogicType = MakeLogicType<
+ externalIssueAssigneesLogicValues,
+ externalIssueAssigneesLogicActions,
+ ExternalIssueAssigneesLogicProps,
+ externalIssueAssigneesLogicMeta
+>
+
+const NO_ASSIGNEES: IntegrationAssigneesResponseApi = { users: [], reconnect_required: false }
+
+async function fetchAssignees(
+ { integrationId, kind, scope }: ExternalIssueAssigneesLogicProps,
+ search: string
+): Promise<IntegrationAssigneesResponseApi> {
+ const projectId = String(teamLogic.values.currentTeamId)
+ switch (kind) {
+ case 'gitlab':
+ return await integrationsGitlabMembersRetrieve(projectId, integrationId, { search })
+ case 'linear':
+ return scope
+ ? await integrationsLinearTeamMembersRetrieve(projectId, integrationId, { team_id: scope, search })
+ : NO_ASSIGNEES
+ case 'github':
+ return scope
+ ? await integrationsGithubAssigneesRetrieve(projectId, integrationId, { repository: scope, search })
+ : NO_ASSIGNEES
+ case 'jira':
+ return scope
+ ? await integrationsJiraAssignableUsersRetrieve(projectId, integrationId, {
+ project_key: scope,
+ search,
+ })
+ : NO_ASSIGNEES
+ }
+}
+
+export const externalIssueAssigneesLogic: LogicWrapper<externalIssueAssigneesLogicType> =
+ kea<externalIssueAssigneesLogicType>([
+ props({} as ExternalIssueAssigneesLogicProps),
+ key((props) => `${props.integrationId}:${props.scope ?? ''}`),
+ path((key) => ['products', 'error_tracking', 'components', 'externalIssueAssigneesLogic', key]),
+ actions({
+ setSearch: (search: string) => ({ search }),
+ }),
+ reducers({
+ // A selected user can drop out of later search results, and the picker would then show their raw ID.
+ knownUserNames: [
+ {} as Record<string, string>,
+ {
+ loadAssigneesSuccess: (state, { assignees }) => ({
+ ...state,
+ ...Object.fromEntries(assignees.users.map((user) => [user.id, user.name])),
+ }),
+ },
+ ],
+ }),
+ loaders(({ props }) => ({
+ assignees: [
+ null as IntegrationAssigneesResponseApi | null,
+ {
+ loadAssignees: async (search: string, breakpoint) => {
+ const assignees = await fetchAssignees(props, search)
+ breakpoint()
+ return assignees
+ },
+ },
+ ],
+ })),
+ listeners(({ actions }) => ({
+ setSearch: async ({ search }, breakpoint) => {
+ await breakpoint(300)
+ actions.loadAssignees(search)
+ },
+ })),
+ afterMount(({ actions }) => {
+ actions.loadAssignees('')
+ }),
+ ])
diff --git a/products/error_tracking/frontend/generated/api.schemas.ts b/products/error_tracking/frontend/generated/api.schemas.ts
index 4ac6360af895..7a0afaf2d35d 100644
--- a/products/error_tracking/frontend/generated/api.schemas.ts
+++ b/products/error_tracking/frontend/generated/api.schemas.ts
@@ -724,7 +724,7 @@ export interface PaginatedErrorTrackingExternalReferenceResultListApi {
}
/**
- * Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}.
+ * Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID.
*/
export type ErrorTrackingExternalReferenceCreateApiConfig = { [key: string]: string }
@@ -744,7 +744,7 @@ export interface ErrorTrackingExternalReferenceCreateApi {
readonly title: string
/** ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira'). */
integration_id: number
- /** Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. */
+ /** Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID. */
config: ErrorTrackingExternalReferenceCreateApiConfig
/** ID of the error tracking issue to link the reference to. */
issue: string
diff --git a/products/error_tracking/frontend/generated/api.zod.ts b/products/error_tracking/frontend/generated/api.zod.ts
index d8f3e6c52482..91021940fe46 100644
--- a/products/error_tracking/frontend/generated/api.zod.ts
+++ b/products/error_tracking/frontend/generated/api.zod.ts
@@ -376,7 +376,7 @@ export const ErrorTrackingExternalReferencesCreateBody = /* @__PURE__ */ zod
config: zod
.record(zod.string(), zod.string())
.describe(
- 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.'
+ 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}. Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID.'
),
issue: zod.uuid().describe('ID of the error tracking issue to link the reference to.'),
})
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
index 9cb1d92e95c8..fe1a2621fbd6 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
@@ -784,6 +784,7 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicType
issue_id: props.id,
destination: response.integration.kind,
stacktrace_included: includeStacktrace,
+ assignee_set: !!config.assignee,
})
const externalIssues = values.issue.external_issues ?? []
return { ...values.issue, external_issues: [...externalIssues, response] }
diff --git a/products/error_tracking/mcp/tools.yaml b/products/error_tracking/mcp/tools.yaml
index 43985a6b2b1f..af9f71e707b5 100644
--- a/products/error_tracking/mcp/tools.yaml
+++ b/products/error_tracking/mcp/tools.yaml
@@ -157,8 +157,9 @@ tools:
GitHub config {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace and reproduction
details"}; GitLab config {"title":"Checkout TypeError","body":"Stack trace and reproduction details"}.
Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body};
- linear -> {team_id, title, description}; jira -> {project_key, title, description}. Use integrations-list
- first to find the `integration_id` and kind; use integrations-jira-projects-retrieve,
+ linear -> {team_id, title, description}; jira -> {project_key, title, description}. Every kind also accepts
+ an optional `assignee` key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID. Use
+ integrations-list first to find the `integration_id` and kind; use integrations-jira-projects-retrieve,
integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific
IDs.
error-tracking-external-references-destroy:
diff --git a/products/integrations/frontend/generated/api.schemas.ts b/products/integrations/frontend/generated/api.schemas.ts
index bf0652a206da..9f1ea0b3fe3e 100644
--- a/products/integrations/frontend/generated/api.schemas.ts
+++ b/products/integrations/frontend/generated/api.schemas.ts
@@ -346,6 +346,20 @@ export interface PatchedIntegrationConfigApi {
readonly installation_status?: InstallationStatusEnumApi | null
}
+export interface IntegrationAssigneeApi {
+ /** Provider user identifier to pass as error tracking config.assignee: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID. */
+ id: string
+ /** User display name. */
+ name: string
+}
+
+export interface IntegrationAssigneesResponseApi {
+ /** Users who can be assigned an issue, up to 100. */
+ users: IntegrationAssigneeApi[]
+ /** True when the connection lacks the permission to list users. Reconnecting the integration grants it. */
+ reconnect_required: boolean
+}
+
export interface GitHubBranchesResponseApi {
/** List of branch names */
branches: string[]
@@ -877,6 +891,18 @@ export type IntegrationsChannelsRetrieveParams = {
search?: string
}
+export type IntegrationsGithubAssigneesRetrieveParams = {
+ /**
+ * Repository name, or owner/name, whose assignable users to list.
+ * @minLength 1
+ */
+ repository: string
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string
+}
+
export type IntegrationsGithubBranchesRetrieveParams = {
/**
* Maximum number of branches to return
@@ -940,6 +966,37 @@ export type IntegrationsGithubTeamsRetrieveParams = {
search?: string
}
+export type IntegrationsGitlabMembersRetrieveParams = {
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string
+}
+
+export type IntegrationsJiraAssignableUsersRetrieveParams = {
+ /**
+ * Jira project key whose assignable users to list.
+ * @minLength 1
+ */
+ project_key: string
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string
+}
+
+export type IntegrationsLinearTeamMembersRetrieveParams = {
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string
+ /**
+ * Linear team ID whose members to list.
+ * @minLength 1
+ */
+ team_id: string
+}
+
export type IntegrationsUsersRetrieveParams = {
/**
* Bypass the 1 hour member cache. Honored only for browser session callers; API key, OAuth, and MCP callers always read through the cache.
diff --git a/products/integrations/frontend/generated/api.ts b/products/integrations/frontend/generated/api.ts
index 74c5d1d2ed75..54bdf2e0adc4 100644
--- a/products/integrations/frontend/generated/api.ts
+++ b/products/integrations/frontend/generated/api.ts
@@ -20,11 +20,16 @@ import type {
GitHubTeamsResponseApi,
IntegrationAccessRequestApi,
IntegrationAccessRequestResponseApi,
+ IntegrationAssigneesResponseApi,
IntegrationConfigApi,
IntegrationsChannelsRetrieveParams,
+ IntegrationsGithubAssigneesRetrieveParams,
IntegrationsGithubBranchesRetrieveParams,
IntegrationsGithubReposRetrieveParams,
IntegrationsGithubTeamsRetrieveParams,
+ IntegrationsGitlabMembersRetrieveParams,
+ IntegrationsJiraAssignableUsersRetrieveParams,
+ IntegrationsLinearTeamMembersRetrieveParams,
IntegrationsListParams,
IntegrationsUsersRetrieveParams,
JiraProjectsResponseApi,
@@ -410,6 +415,41 @@ export const integrationsEmailVerifyCreate = async (
})
}
+export const getIntegrationsGithubAssigneesRetrieveUrl = (
+ projectId: string,
+ id: number,
+ params: IntegrationsGithubAssigneesRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/projects/${projectId}/integrations/${id}/github_assignees/?${stringifiedParams}`
+ : `/api/projects/${projectId}/integrations/${id}/github_assignees/`
+}
+
+export const integrationsGithubAssigneesRetrieve = async (
+ projectId: string,
+ id: number,
+ params: IntegrationsGithubAssigneesRetrieveParams,
+ options?: RequestInit
+): Promise<IntegrationAssigneesResponseApi> => {
+ return apiMutator<IntegrationAssigneesResponseApi>(
+ getIntegrationsGithubAssigneesRetrieveUrl(projectId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
export const getIntegrationsGithubBranchesRetrieveUrl = (
projectId: string,
id: number,
@@ -521,6 +561,38 @@ export const integrationsGithubTeamsRetrieve = async (
})
}
+export const getIntegrationsGitlabMembersRetrieveUrl = (
+ projectId: string,
+ id: number,
+ params?: IntegrationsGitlabMembersRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/projects/${projectId}/integrations/${id}/gitlab_members/?${stringifiedParams}`
+ : `/api/projects/${projectId}/integrations/${id}/gitlab_members/`
+}
+
+export const integrationsGitlabMembersRetrieve = async (
+ projectId: string,
+ id: number,
+ params?: IntegrationsGitlabMembersRetrieveParams,
+ options?: RequestInit
+): Promise<IntegrationAssigneesResponseApi> => {
+ return apiMutator<IntegrationAssigneesResponseApi>(getIntegrationsGitlabMembersRetrieveUrl(projectId, id, params), {
+ ...options,
+ method: 'GET',
+ })
+}
+
export const getIntegrationsGoogleAccessibleAccountsRetrieveUrl = (projectId: string, id: number) => {
return `/api/projects/${projectId}/integrations/${id}/google_accessible_accounts/`
}
@@ -551,6 +623,41 @@ export const integrationsGoogleConversionActionsRetrieve = async (
})
}
+export const getIntegrationsJiraAssignableUsersRetrieveUrl = (
+ projectId: string,
+ id: number,
+ params: IntegrationsJiraAssignableUsersRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/projects/${projectId}/integrations/${id}/jira_assignable_users/?${stringifiedParams}`
+ : `/api/projects/${projectId}/integrations/${id}/jira_assignable_users/`
+}
+
+export const integrationsJiraAssignableUsersRetrieve = async (
+ projectId: string,
+ id: number,
+ params: IntegrationsJiraAssignableUsersRetrieveParams,
+ options?: RequestInit
+): Promise<IntegrationAssigneesResponseApi> => {
+ return apiMutator<IntegrationAssigneesResponseApi>(
+ getIntegrationsJiraAssignableUsersRetrieveUrl(projectId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
export const getIntegrationsJiraProjectsRetrieveUrl = (projectId: string, id: number) => {
return `/api/projects/${projectId}/integrations/${id}/jira_projects/`
}
@@ -566,6 +673,41 @@ export const integrationsJiraProjectsRetrieve = async (
})
}
+export const getIntegrationsLinearTeamMembersRetrieveUrl = (
+ projectId: string,
+ id: number,
+ params: IntegrationsLinearTeamMembersRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/projects/${projectId}/integrations/${id}/linear_team_members/?${stringifiedParams}`
+ : `/api/projects/${projectId}/integrations/${id}/linear_team_members/`
+}
+
+export const integrationsLinearTeamMembersRetrieve = async (
+ projectId: string,
+ id: number,
+ params: IntegrationsLinearTeamMembersRetrieveParams,
+ options?: RequestInit
+): Promise<IntegrationAssigneesResponseApi> => {
+ return apiMutator<IntegrationAssigneesResponseApi>(
+ getIntegrationsLinearTeamMembersRetrieveUrl(projectId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
export const getIntegrationsLinearTeamsRetrieveUrl = (projectId: string, id: number) => {
return `/api/projects/${projectId}/integrations/${id}/linear_teams/`
}
diff --git a/products/integrations/mcp/tools.yaml b/products/integrations/mcp/tools.yaml
index 5f188fd2e907..bcc82edf3d9c 100644
--- a/products/integrations/mcp/tools.yaml
+++ b/products/integrations/mcp/tools.yaml
@@ -100,6 +100,9 @@ tools:
integrations-environment-mapping-partial-update:
operation: integrations_environment_mapping_partial_update
enabled: false
+ integrations-github-assignees-retrieve:
+ operation: integrations_github_assignees_retrieve
+ enabled: false
integrations-github-available-installations-retrieve:
operation: integrations_github_available_installations_retrieve
enabled: false
@@ -142,12 +145,18 @@ tools:
integrations-github-teams-retrieve:
operation: integrations_github_teams_retrieve
enabled: false
+ integrations-gitlab-members-retrieve:
+ operation: integrations_gitlab_members_retrieve
+ enabled: false
integrations-google-accessible-accounts-retrieve:
operation: integrations_google_accessible_accounts_retrieve
enabled: false
integrations-google-conversion-actions-retrieve:
operation: integrations_google_conversion_actions_retrieve
enabled: false
+ integrations-jira-assignable-users-retrieve:
+ operation: integrations_jira_assignable_users_retrieve
+ enabled: false
integrations-jira-projects-retrieve:
operation: integrations_jira_projects_retrieve
enabled: true
@@ -162,6 +171,9 @@ tools:
List Jira projects available through a connected Jira integration. Use integrations-list with kind=jira
first to find the integration id, then pass a returned project key as `config.project_key` when creating an
error tracking external reference.
+ integrations-linear-team-members-retrieve:
+ operation: integrations_linear_team_members_retrieve
+ enabled: false
integrations-linear-teams-retrieve:
operation: integrations_linear_teams_retrieve
enabled: true
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 05c1d9f120cd..5a52512e0e99 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -4589,7 +4589,7 @@
}
},
"error-tracking-external-references-create": {
- "description": "Create a new external issue in GitHub, GitLab, Linear, or Jira, then link it to a PostHog error tracking issue as an external reference. This tool does not link an existing external issue by URL or key. Provide the error tracking issue id as `issue`, the connected integration as `integration_id`, and a `config` object with provider-specific fields. Examples: Jira config {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; Linear config {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; GitHub config {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}; GitLab config {\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}. Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Use integrations-list first to find the `integration_id` and kind; use integrations-jira-projects-retrieve, integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific IDs.",
+ "description": "Create a new external issue in GitHub, GitLab, Linear, or Jira, then link it to a PostHog error tracking issue as an external reference. This tool does not link an existing external issue by URL or key. Provide the error tracking issue id as `issue`, the connected integration as `integration_id`, and a `config` object with provider-specific fields. Examples: Jira config {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; Linear config {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; GitHub config {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}; GitLab config {\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}. Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Every kind also accepts an optional `assignee` key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID. Use integrations-list first to find the `integration_id` and kind; use integrations-jira-projects-retrieve, integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific IDs.",
"category": "Error tracking",
"feature": "error_tracking",
"summary": "Create error tracking external reference",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 1e476132b307..75b318634072 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -4618,7 +4618,7 @@
}
},
"error-tracking-external-references-create": {
- "description": "Create a new external issue in GitHub, GitLab, Linear, or Jira, then link it to a PostHog error tracking issue as an external reference. This tool does not link an existing external issue by URL or key. Provide the error tracking issue id as `issue`, the connected integration as `integration_id`, and a `config` object with provider-specific fields. Examples: Jira config {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; Linear config {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; GitHub config {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}; GitLab config {\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}. Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Use integrations-list first to find the `integration_id` and kind; use integrations-jira-projects-retrieve, integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific IDs.",
+ "description": "Create a new external issue in GitHub, GitLab, Linear, or Jira, then link it to a PostHog error tracking issue as an external reference. This tool does not link an existing external issue by URL or key. Provide the error tracking issue id as `issue`, the connected integration as `integration_id`, and a `config` object with provider-specific fields. Examples: Jira config {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; Linear config {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; GitHub config {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}; GitLab config {\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}. Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Every kind also accepts an optional `assignee` key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID. Use integrations-list first to find the `integration_id` and kind; use integrations-jira-projects-retrieve, integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific IDs.",
"category": "Error tracking",
"feature": "error_tracking",
"summary": "Create error tracking external reference",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 863dc1ba7562..4e781ec5a52d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -38746,7 +38746,7 @@ export namespace Schemas {
}
/**
- * Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}.
+ * Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID.
*/
export type ErrorTrackingExternalReferenceCreateConfig = {[key: string]: string};
@@ -38775,7 +38775,7 @@ export namespace Schemas {
readonly title: string;
/** ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira'). */
integration_id: number;
- /** Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. */
+ /** Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID. */
config: ErrorTrackingExternalReferenceCreateConfig;
/** ID of the error tracking issue to link the reference to. */
issue: string;
@@ -57510,6 +57510,20 @@ export namespace Schemas {
accounts: IntegrationAccount[];
}
+ export interface IntegrationAssignee {
+ /** Provider user identifier to pass as error tracking config.assignee: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID. */
+ id: string;
+ /** User display name. */
+ name: string;
+ }
+
+ export interface IntegrationAssigneesResponse {
+ /** Users who can be assigned an issue, up to 100. */
+ users: IntegrationAssignee[];
+ /** True when the connection lacks the permission to list users. Reconnecting the integration grants it. */
+ reconnect_required: boolean;
+ }
+
/**
* Standard Integration serializer.
*/
@@ -119890,6 +119904,18 @@ export namespace Schemas {
search?: string;
};
+ export type IntegrationsGithubAssigneesRetrieveParams = {
+ /**
+ * Repository name, or owner/name, whose assignable users to list.
+ * @minLength 1
+ */
+ repository: string;
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string;
+ };
+
export type IntegrationsGithubBranchesRetrieveParams = {
/**
* Maximum number of branches to return
@@ -119953,6 +119979,37 @@ export namespace Schemas {
search?: string;
};
+ export type IntegrationsGitlabMembersRetrieveParams = {
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string;
+ };
+
+ export type IntegrationsJiraAssignableUsersRetrieveParams = {
+ /**
+ * Jira project key whose assignable users to list.
+ * @minLength 1
+ */
+ project_key: string;
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string;
+ };
+
+ export type IntegrationsLinearTeamMembersRetrieveParams = {
+ /**
+ * Optional case-insensitive name search. Leave blank to list the first users.
+ */
+ search?: string;
+ /**
+ * Linear team ID whose members to list.
+ * @minLength 1
+ */
+ team_id: string;
+ };
+
export type IntegrationsUsersRetrieveParams = {
/**
* Bypass the 1 hour member cache. Honored only for browser session callers; API key, OAuth, and MCP callers always read through the cache.
diff --git a/services/mcp/src/generated/error_tracking/api.ts b/services/mcp/src/generated/error_tracking/api.ts
index 469fbe249d4d..d86446423f9e 100644
--- a/services/mcp/src/generated/error_tracking/api.ts
+++ b/services/mcp/src/generated/error_tracking/api.ts
@@ -4794,7 +4794,7 @@ export const ErrorTrackingExternalReferencesCreateBody = () => zod
config: zod
.record(zod.string(), zod.string())
.describe(
- 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.'
+ 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}. Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID.'
),
issue: zod.string().describe('ID of the error tracking issue to link the reference to.'),
})
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-external-references-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-external-references-create.json
index 540d486e89f1..edc703ce2899 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-external-references-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-external-references-create.json
@@ -6,7 +6,7 @@
"additionalProperties": {
"type": "string"
},
- "description": "Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.",
+ "description": "Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}. Every kind also accepts an optional assignee key: a Linear user ID, a GitHub login, a GitLab user ID, or a Jira account ID.",
"propertyNames": {
"type": "string"
},