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.

fix(error-tracking): preserve integer user assignee id on issue fetch (#64834)

Aleksander Błaszkiewicz35166944ee97
diff --git a/products/error_tracking/backend/presentation/views/issues.py b/products/error_tracking/backend/presentation/views/issues.py
index c19c0fe4c673..97ad67d1db91 100644
--- a/products/error_tracking/backend/presentation/views/issues.py
+++ b/products/error_tracking/backend/presentation/views/issues.py
@@ -46,9 +46,16 @@ logger = structlog.get_logger(__name__)
class ErrorTrackingIssueAssigneeReadSerializer(serializers.Serializer):
- id = serializers.CharField(allow_null=True)
+ # User assignees carry an integer id, role assignees a UUID string. `CharField` would
+ # coerce the user id to a string, which the frontend assignee resolver compares with
+ # `===` against the numeric member id — failing to resolve and rendering "Unassigned".
+ id = serializers.SerializerMethodField()
type = serializers.CharField()
+ @extend_schema_field({"oneOf": [{"type": "integer"}, {"type": "string"}], "nullable": True})
+ def get_id(self, obj) -> int | str | None:
+ return obj.id
+
class ErrorTrackingIssueCohortReadSerializer(serializers.Serializer):
id = serializers.IntegerField()
diff --git a/products/error_tracking/backend/tests/api/test_error_tracking_api.py b/products/error_tracking/backend/tests/api/test_error_tracking_api.py
index fca5295ca4fd..0a62acb1d0ee 100644
--- a/products/error_tracking/backend/tests/api/test_error_tracking_api.py
+++ b/products/error_tracking/backend/tests/api/test_error_tracking_api.py
@@ -110,6 +110,29 @@ class TestErrorTracking(APIBaseTest):
"external_issues": [],
}
+ @parameterized.expand(["user", "role"])
+ def test_issue_fetch_assignee_id_preserves_type(self, assignee_type):
+ # The frontend resolves the assignee by strict-comparing the numeric member id with
+ # `assignee.id`; if retrieve serializes the user id as a string the issue renders as
+ # "Unassigned" despite being assigned. User ids must stay integers, role ids strings.
+ issue = self.create_issue(["fingerprint"])
+ expected_id: int | str
+ expected_python_type: type
+ if assignee_type == "user":
+ ErrorTrackingIssueAssignment.objects.create(issue=issue, user=self.user)
+ expected_id, expected_python_type = self.user.id, int
+ else:
+ role = Role.objects.create(name="Eng role", organization=self.organization)
+ ErrorTrackingIssueAssignment.objects.create(issue=issue, role=role)
+ expected_id, expected_python_type = str(role.id), str
+
+ response = self.client.get(f"/api/environments/{self.team.id}/error_tracking/issues/{issue.id}")
+
+ assert response.status_code == 200
+ assignee = response.json()["assignee"]
+ assert assignee == {"id": expected_id, "type": assignee_type}
+ assert isinstance(assignee["id"], expected_python_type)
+
@freeze_time("2025-01-01")
def test_issue_update(self):
issue = self.create_issue(["fingerprint"])