: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(platform): return frozen dataclasses instead of tuples (#76137)
Arno Hillene124cf821dc0
diff --git a/ee/api/scim/views.py b/ee/api/scim/views.pyindex eb0dc34cd666..4c0fe65371dd 100644--- a/ee/api/scim/views.py+++ b/ee/api/scim/views.py@@ -18,6 +18,7 @@ from rest_framework.response import Responsefrom rest_framework.views import APIViewfrom scim2_filter_parser.transpilers.django_q_object import get_query+from posthog.dataclasses import frozenfrom posthog.exceptions_capture import capture_exceptionfrom posthog.models import Userfrom posthog.models.activity_logging.activity_log import ActivityContextBase, Detail, log_activity@@ -50,10 +51,16 @@ class SCIMPaginationError(Exception):super().__init__(detail)-def _parse_scim_pagination(request: Request) -> tuple[int, int]:+@frozen+class ScimPagination:+ start_index: int+ count: int+++def _parse_scim_pagination(request: Request) -> ScimPagination:"""Parse startIndex and count from SCIM query params.- Returns (start_index, count) following django-scim2 conventions.+ Returns a ScimPagination following django-scim2 conventions.Raises SCIMPaginationError for invalid values."""try:@@ -73,29 +80,29 @@ def _parse_scim_pagination(request: Request) -> tuple[int, int]:raise SCIMPaginationError("Invalid count (must be >= 0)")count = min(count, MAX_ITEMS_PER_PAGE)- return start_index, count+ return ScimPagination(start_index=start_index, count=count)def _build_scim_list_response(queryset: QuerySet,- start_index: int,- count: int,+ *,+ pagination: ScimPagination,adapter_cls: type[PostHogSCIMUser] | type[PostHogSCIMGroup],config: IdentityProviderConfig,) -> dict:total_results = queryset.count()- if count == 0:+ if pagination.count == 0:resources: list[dict] = []else:- offset = start_index - 1- page = queryset[offset : offset + count]+ offset = pagination.start_index - 1+ page = queryset[offset : offset + pagination.count]resources = [adapter_cls(obj, config).to_dict() for obj in page]return {"schemas": [constants.SchemaURI.LIST_RESPONSE],"totalResults": total_results,- "startIndex": start_index,+ "startIndex": pagination.start_index,"itemsPerPage": len(resources),"Resources": resources,}@@ -312,7 +319,7 @@ class SCIMUsersView(SCIMBaseView):filter_param = request.query_params.get("filter")try:- start_index, count = _parse_scim_pagination(request)+ pagination = _parse_scim_pagination(request)except SCIMPaginationError as e:return Response({"schemas": [constants.SchemaURI.ERROR], "status": 400, "detail": e.detail},@@ -336,7 +343,9 @@ class SCIMUsersView(SCIMBaseView):else:queryset = PostHogSCIMUser.get_queryset_for_organization(config)- return Response(_build_scim_list_response(queryset, start_index, count, PostHogSCIMUser, config))+ return Response(+ _build_scim_list_response(queryset, pagination=pagination, adapter_cls=PostHogSCIMUser, config=config)+ )def post(self, request: Request, scim_slug: str) -> Response:config = cast(IdentityProviderConfig, request.auth)@@ -479,7 +488,7 @@ class SCIMGroupsView(SCIMBaseView):filter_param = request.query_params.get("filter")try:- start_index, count = _parse_scim_pagination(request)+ pagination = _parse_scim_pagination(request)except SCIMPaginationError as e:return Response({"schemas": [constants.SchemaURI.ERROR], "status": 400, "detail": e.detail},@@ -503,7 +512,9 @@ class SCIMGroupsView(SCIMBaseView):else:queryset = PostHogSCIMGroup.get_queryset_for_organization(config)- return Response(_build_scim_list_response(queryset, start_index, count, PostHogSCIMGroup, config))+ return Response(+ _build_scim_list_response(queryset, pagination=pagination, adapter_cls=PostHogSCIMGroup, config=config)+ )def post(self, request: Request, scim_slug: str) -> Response:config = cast(IdentityProviderConfig, request.auth)diff --git a/posthog/hogql/printer/access_control.py b/posthog/hogql/printer/access_control.pyindex bcfaedea5b18..f087fbfcc450 100644--- a/posthog/hogql/printer/access_control.py+++ b/posthog/hogql/printer/access_control.py@@ -75,7 +75,7 @@ def build_access_control_guard(type=ast.BooleanType(),)else:- blocked_ids = user_access_control.blocked_resource_ids_by_scope.get(resource, set())+ blocked_ids = user_access_control.blocked_resource_ids_by_scope.get(resource, frozenset())if not blocked_ids:return Noneguard = ast.CompareOperation(diff --git a/posthog/models/activity_logging/batch_export_utils.py b/posthog/models/activity_logging/batch_export_utils.pyindex 815d96cdf5fe..58a30b907427 100644--- a/posthog/models/activity_logging/batch_export_utils.py+++ b/posthog/models/activity_logging/batch_export_utils.py@@ -1,4 +1,4 @@-from typing import Optional+from posthog.models.activity_logging.utils import CreatedByInfodef get_batch_export_destination_type(batch_export) -> str:@@ -12,7 +12,7 @@ def get_batch_export_destination_type(batch_export) -> str:return destination_type-def get_batch_export_created_by_info(batch_export) -> tuple[Optional[str], Optional[str], Optional[str]]:+def get_batch_export_created_by_info(batch_export) -> CreatedByInfo:"""Get created by user information from BatchExport"""created_by_user_id = Nonecreated_by_user_email = None@@ -23,7 +23,7 @@ def get_batch_export_created_by_info(batch_export) -> tuple[Optional[str], Optiocreated_by_user_email = batch_export.created_by.emailcreated_by_user_name = f"{batch_export.created_by.first_name} {batch_export.created_by.last_name}".strip()- return created_by_user_id, created_by_user_email, created_by_user_name+ return CreatedByInfo(user_id=created_by_user_id, email=created_by_user_email, name=created_by_user_name)def get_batch_export_detail_name(batch_export, destination_type: str) -> str:diff --git a/posthog/models/activity_logging/external_data_utils.py b/posthog/models/activity_logging/external_data_utils.pyindex 3ec77e0f5cd3..2bbab390f47e 100644--- a/posthog/models/activity_logging/external_data_utils.py+++ b/posthog/models/activity_logging/external_data_utils.py@@ -1,4 +1,4 @@-from typing import Optional+from posthog.models.activity_logging.utils import CreatedByInfofrom products.warehouse_sources.backend.facade.models import ExternalDataSource@@ -15,7 +15,7 @@ def get_external_data_source_detail_name(external_data_source: ExternalDataSourcdef get_external_data_source_created_by_info(external_data_source: ExternalDataSource,-) -> tuple[Optional[str], Optional[str], Optional[str]]:+) -> CreatedByInfo:"""Get created by user information from ExternalDataSource"""created_by_user_id = Nonecreated_by_user_email = None@@ -28,4 +28,4 @@ def get_external_data_source_created_by_info(f"{external_data_source.created_by.first_name} {external_data_source.created_by.last_name}".strip())- return created_by_user_id, created_by_user_email, created_by_user_name+ return CreatedByInfo(user_id=created_by_user_id, email=created_by_user_email, name=created_by_user_name)diff --git a/posthog/models/activity_logging/signal_handlers.py b/posthog/models/activity_logging/signal_handlers.pyindex 2b62b6849e64..f897aa270d9f 100644--- a/posthog/models/activity_logging/signal_handlers.py+++ b/posthog/models/activity_logging/signal_handlers.py@@ -651,15 +651,15 @@ def handle_tagged_item_change(if not tagged_item or not tagged_item.tag:return- related_object_type, related_object_id, related_object_name = get_tagged_item_related_object_info(tagged_item)+ related_object = get_tagged_item_related_object_info(tagged_item)context = TaggedItemContext(tag_name=tagged_item.tag.name,tag_id=str(tagged_item.tag.id),team_id=tagged_item.tag.team_id,- related_object_type=related_object_type,- related_object_id=related_object_id,- related_object_name=related_object_name,+ related_object_type=related_object.type,+ related_object_id=related_object.id,+ related_object_name=related_object.name,)team = tagged_item.tag.team@@ -686,19 +686,19 @@ def handle_tagged_item_change(# Mirror the tag change onto the related object's own activity stream# (e.g. so a tag added to a Ticket shows up on that ticket's timeline).- related_logger = RELATED_OBJECT_ACTIVITY_LOGGERS.get(related_object_type or "")- if related_logger and related_object_id:+ related_logger = RELATED_OBJECT_ACTIVITY_LOGGERS.get(related_object.type or "")+ if related_logger and related_object.id:tag_action: Literal["created", "deleted"] = "created" if activity == "created" else "deleted"log_activity(organization_id=organization_id,team_id=team_id,user=user,was_impersonated=was_impersonated,- item_id=related_object_id,+ item_id=related_object.id,scope=related_logger.scope,activity="updated",detail=Detail(- name=related_logger.resolve_name(tagged_item, related_object_name),+ name=related_logger.resolve_name(tagged_item, related_object.name),changes=[Change(type=related_logger.scope,diff --git a/posthog/models/activity_logging/tag_utils.py b/posthog/models/activity_logging/tag_utils.pyindex f2c92e8b6215..618bc91a099d 100644--- a/posthog/models/activity_logging/tag_utils.py+++ b/posthog/models/activity_logging/tag_utils.py@@ -1,9 +1,15 @@-from typing import Optional-+from posthog.dataclasses import frozenfrom posthog.models.tagged_item import RELATED_OBJECTS-def get_tagged_item_related_object_info(tagged_item) -> tuple[Optional[str], Optional[str], Optional[str]]:+@frozen+class RelatedObjectInfo:+ type: str | None+ id: str | None+ name: str | None+++def get_tagged_item_related_object_info(tagged_item) -> RelatedObjectInfo:related_object_type = Nonerelated_object_id = Nonerelated_object_name = None@@ -26,4 +32,4 @@ def get_tagged_item_related_object_info(tagged_item) -> tuple[Optional[str], Optrelated_object_name = related_obj.labelbreak- return related_object_type, related_object_id, related_object_name+ return RelatedObjectInfo(type=related_object_type, id=related_object_id, name=related_object_name)diff --git a/posthog/models/activity_logging/utils.py b/posthog/models/activity_logging/utils.pyindex 80bd5af94458..941c478659b3 100644--- a/posthog/models/activity_logging/utils.py+++ b/posthog/models/activity_logging/utils.py@@ -7,6 +7,8 @@ from django.db.models import Q, QuerySetimport structlogfrom asgiref.local import Local+from posthog.dataclasses import frozen+if TYPE_CHECKING:from posthog.models.activity_logging.activity_log import ActivityLog, Trigger@@ -16,6 +18,13 @@ ACTIVITY_LOG_CLIENT_HEADER = "x-posthog-client"ACTIVITY_LOG_CLIENT_MAX_LENGTH = 32+@frozen+class CreatedByInfo:+ user_id: str | None+ email: str | None+ name: str | None++class ActivityLoggingStorage:"""Thread-safe storage for activity logging context using asgiref.local.diff --git a/posthog/models/resource_transfer/test/test_visitors.py b/posthog/models/resource_transfer/test/test_visitors.pyindex 4d774b33bfe9..303a2bcad6b2 100644--- a/posthog/models/resource_transfer/test/test_visitors.py+++ b/posthog/models/resource_transfer/test/test_visitors.py@@ -1220,9 +1220,9 @@ class TestExperimentPayloadDynamicEdgeExtraction(SimpleTestCase):}],)- cohort_ids, action_ids = collect_cohort_and_action_ids_from_experiment_json(resource)- assert cohort_ids == {600}- assert action_ids == {501}+ collected = collect_cohort_and_action_ids_from_experiment_json(resource)+ assert collected.cohort_ids == {600}+ assert collected.action_ids == {501}def test_collect_ids_from_filters_and_parameters_keys(self) -> None:# Top-level experiment ``filters`` often mirrors insight shapes nested under keys;@@ -1241,9 +1241,9 @@ class TestExperimentPayloadDynamicEdgeExtraction(SimpleTestCase):}},)- cohort_ids, action_ids = collect_cohort_and_action_ids_from_experiment_json(resource)- assert 111 in cohort_ids- assert 222 in action_ids+ collected = collect_cohort_and_action_ids_from_experiment_json(resource)+ assert 111 in collected.cohort_ids+ assert 222 in collected.action_idsclass TestExperimentVisitorDynamicEdges(SimpleTestCase):diff --git a/posthog/models/resource_transfer/visitors/common.py b/posthog/models/resource_transfer/visitors/common.pyindex cb9d6a39cb67..f8cdf93c0c09 100644--- a/posthog/models/resource_transfer/visitors/common.py+++ b/posthog/models/resource_transfer/visitors/common.py@@ -11,7 +11,10 @@ place.from __future__ import annotations-from collections.abc import Callable+from collections.abc import (+ Callable,+ Set as AbstractSet,+)from typing import Anyfrom django.db import models@@ -157,7 +160,7 @@ def make_json_id_rewriter(def build_edges_for_ids(- ids: set[int],+ ids: AbstractSet[int],target_model: type[models.Model],label_prefix: str,rewrite_fn: RewritePayloadFn,diff --git a/posthog/models/resource_transfer/visitors/experiment.py b/posthog/models/resource_transfer/visitors/experiment.pyindex a506e6a7dd18..df96f15095a2 100644--- a/posthog/models/resource_transfer/visitors/experiment.py+++ b/posthog/models/resource_transfer/visitors/experiment.py@@ -44,9 +44,13 @@ class ExperimentVisitor(@classmethoddef get_dynamic_edges(cls, resource: Any) -> list[ResourceTransferEdge]:- cohort_ids, action_ids = collect_cohort_and_action_ids_from_experiment_json(resource)+ collected = collect_cohort_and_action_ids_from_experiment_json(resource)edges: list[ResourceTransferEdge] = []- edges.extend(build_edges_for_ids(cohort_ids, Cohort, "json_cohort", rewrite_cohort_in_experiment_payload))- edges.extend(build_edges_for_ids(action_ids, Action, "json_action", rewrite_action_in_experiment_payload))+ edges.extend(+ build_edges_for_ids(collected.cohort_ids, Cohort, "json_cohort", rewrite_cohort_in_experiment_payload)+ )+ edges.extend(+ build_edges_for_ids(collected.action_ids, Action, "json_action", rewrite_action_in_experiment_payload)+ )return edgesdiff --git a/posthog/models/resource_transfer/visitors/experiment_payload.py b/posthog/models/resource_transfer/visitors/experiment_payload.pyindex e2a0a9069295..15388bbfce18 100644--- a/posthog/models/resource_transfer/visitors/experiment_payload.py+++ b/posthog/models/resource_transfer/visitors/experiment_payload.py@@ -7,11 +7,18 @@ from __future__ import annotationsfrom typing import Any+from posthog.dataclasses import frozenfrom posthog.models.resource_transfer.types import ResourcePayloadfrom posthog.models.resource_transfer.visitors.insight import InsightVisitor-def collect_cohort_and_action_ids_from_experiment_json(resource: Any) -> tuple[set[int], set[int]]:+@frozen+class CollectedResourceIds:+ cohort_ids: frozenset[int]+ action_ids: frozenset[int]+++def collect_cohort_and_action_ids_from_experiment_json(resource: Any) -> CollectedResourceIds:cohort_ids: set[int] = set()action_ids: set[int] = set()@@ -25,14 +32,14 @@ def collect_cohort_and_action_ids_from_experiment_json(resource: Any) -> tuple[sresource.scheduling_config,resource.variants,):- c, a = _collect_ids_from_json_blob(blob)- cohort_ids.update(c)- action_ids.update(a)+ collected = _collect_ids_from_json_blob(blob)+ cohort_ids.update(collected.cohort_ids)+ action_ids.update(collected.action_ids)- return cohort_ids, action_ids+ return CollectedResourceIds(cohort_ids=frozenset(cohort_ids), action_ids=frozenset(action_ids))-def _collect_ids_from_json_blob(blob: Any) -> tuple[set[int], set[int]]:+def _collect_ids_from_json_blob(blob: Any) -> CollectedResourceIds:cohort_ids: set[int] = set()action_ids: set[int] = set()@@ -51,7 +58,7 @@ def _collect_ids_from_json_blob(blob: Any) -> tuple[set[int], set[int]]:walk(item)walk(blob)- return cohort_ids, action_ids+ return CollectedResourceIds(cohort_ids=frozenset(cohort_ids), action_ids=frozenset(action_ids))def rewrite_cohort_in_experiment_payload(payload: ResourcePayload, old_pk: Any, new_pk: Any) -> ResourcePayload:diff --git a/posthog/rbac/test/test_user_access_control.py b/posthog/rbac/test/test_user_access_control.pyindex 2af8b43ad5f5..7d00b8f73394 100644--- a/posthog/rbac/test/test_user_access_control.py+++ b/posthog/rbac/test/test_user_access_control.py@@ -2022,8 +2022,8 @@ class TestBlockedResourceIdsByScope(BaseTest):self.uac = UserAccessControl(self.user, self.team)- def _blocked(self, resource="dashboard") -> set[str]:- return self.uac.blocked_resource_ids_by_scope.get(resource, set())+ def _blocked(self, resource="dashboard") -> frozenset[str]:+ return self.uac.blocked_resource_ids_by_scope.get(resource, frozenset())def test_empty_for_org_admin(self):self.membership.level = OrganizationMembership.Level.ADMINdiff --git a/posthog/rbac/test/test_user_access_control_pbt.py b/posthog/rbac/test/test_user_access_control_pbt.pyindex ce60407017b8..8270ddb0f15a 100644--- a/posthog/rbac/test/test_user_access_control_pbt.py+++ b/posthog/rbac/test/test_user_access_control_pbt.py@@ -768,7 +768,7 @@ class TestUserAccessControlProperties(BaseAccessControlPropertyTest):uac = self._fresh_uac()allowlisted = uac.allowlisted_resource_ids_by_scope.get(resource)- blocked = uac.blocked_resource_ids_by_scope.get(resource, set())+ blocked = uac.blocked_resource_ids_by_scope.get(resource, frozenset())model_has_creator = model_has_created_by(model_cls)def guard_admits(object_id: str) -> bool:diff --git a/posthog/rbac/user_access_control.py b/posthog/rbac/user_access_control.pyindex fc49d9bfe0a4..14bf5f5829f0 100644--- a/posthog/rbac/user_access_control.py+++ b/posthog/rbac/user_access_control.py@@ -13,6 +13,7 @@ from opentelemetry import tracefrom rest_framework import serializersfrom posthog.constants import AvailableFeature+from posthog.dataclasses import frozenfrom posthog.models import Organization, OrganizationMembership, Team, Userfrom posthog.scopes import API_SCOPE_OBJECTS, INTERNAL_API_SCOPE_OBJECTS, APIScopeObjectfrom posthog.settings import EE_AVAILABLE@@ -510,6 +511,12 @@ def fallback_parent_object_id(obj: Model, parent_resource: APIScopeObject) -> Opreturn str(parent_id) if parent_id is not None else None+@frozen+class ObjectAccessDecision:+ blocked_ids: frozenset[str]+ allowed_ids: frozenset[str]++class UserAccessControl:"""UserAccessControl provides functions for checking unified access to all resources and objects from a Project level downwards.@@ -1188,28 +1195,28 @@ class UserAccessControl:filters = self._access_controls_filters_for_queryset(resource)access_controls = self._get_access_controls(filters)- blocked_resource_ids, allowed_resource_ids = self._blocked_and_allowed_object_ids(access_controls)+ decision = self._blocked_and_allowed_object_ids(access_controls)# Apply filtering logic based on resource-level access- if not self.has_resource_access(resource) and allowed_resource_ids:+ if not self.has_resource_access(resource) and decision.allowed_ids:# User has "none" resource access but specific object access# Only show objects they have explicit access to (plus created objects)if model_has_creator:- queryset = queryset.filter(Q(id__in=allowed_resource_ids) | Q(created_by=self._user))+ queryset = queryset.filter(Q(id__in=decision.allowed_ids) | Q(created_by=self._user))else:- queryset = queryset.filter(id__in=allowed_resource_ids)- elif blocked_resource_ids:+ queryset = queryset.filter(id__in=decision.allowed_ids)+ elif decision.blocked_ids:# Standard case: exclude explicitly blocked objectsif model_has_creator:- queryset = queryset.exclude(Q(id__in=blocked_resource_ids) & ~Q(created_by=self._user))+ queryset = queryset.exclude(Q(id__in=decision.blocked_ids) & ~Q(created_by=self._user))else:- queryset = queryset.exclude(id__in=blocked_resource_ids)+ queryset = queryset.exclude(id__in=decision.blocked_ids)return queryset- def _blocked_and_allowed_object_ids(self, access_controls: list[_AccessControl]) -> tuple[set[str], set[str]]:+ def _blocked_and_allowed_object_ids(self, access_controls: list[_AccessControl]) -> ObjectAccessDecision:"""Canonical object-level decision over a pool of object access controls (rows with- `resource_id` set), returning (blocked_ids, allowed_ids).+ `resource_id` set), returning an ObjectAccessDecision of blocked and allowed ids.Explicit-wins: if a resource_id has any explicit (role/member) rule, the object isallowed when any explicit rule grants non-"none", otherwise blocked. With no explicit@@ -1250,10 +1257,12 @@ class UserAccessControl:# All explicit access levels are "none" - block this objectblocked_resource_ids.add(resource_id)- return blocked_resource_ids, allowed_resource_ids+ return ObjectAccessDecision(+ blocked_ids=frozenset(blocked_resource_ids), allowed_ids=frozenset(allowed_resource_ids)+ )@cached_property- def blocked_resource_ids_by_scope(self) -> dict[APIScopeObject, set[str]]:+ def blocked_resource_ids_by_scope(self) -> dict[APIScopeObject, frozenset[str]]:"""Per-resource set of object IDs the user is denied (effective access resolves to"none"), built from the single preload via the canonical object resolver.@@ -1273,15 +1282,15 @@ class UserAccessControl:if ac.resource_id is not None:object_rows_by_resource[cast(APIScopeObject, ac.resource)].append(ac)- result: dict[APIScopeObject, set[str]] = {}+ result: dict[APIScopeObject, frozenset[str]] = {}for resource, acs in object_rows_by_resource.items():- blocked, _allowed = self._blocked_and_allowed_object_ids(acs)+ blocked = self._blocked_and_allowed_object_ids(acs).blocked_idsif blocked:result[resource] = blockedreturn result@cached_property- def allowlisted_resource_ids_by_scope(self) -> dict[APIScopeObject, set[str]]:+ def allowlisted_resource_ids_by_scope(self) -> dict[APIScopeObject, frozenset[str]]:"""Per-resource set of object IDs that are the *only* ones the user may read, for resourceswhere they hold object-level grants but no resource-level access at all.@@ -1305,9 +1314,9 @@ class UserAccessControl:if ac.resource_id is not None:object_rows_by_resource[cast(APIScopeObject, ac.resource)].append(ac)- result: dict[APIScopeObject, set[str]] = {}+ result: dict[APIScopeObject, frozenset[str]] = {}for resource, acs in object_rows_by_resource.items():- _blocked, allowed = self._blocked_and_allowed_object_ids(acs)+ allowed = self._blocked_and_allowed_object_ids(acs).allowed_idsif allowed and not self.has_resource_access(resource):result[resource] = allowedreturn resultdiff --git a/products/batch_exports/backend/activity_logging.py b/products/batch_exports/backend/activity_logging.pyindex f97c28efa63f..173c4bfe6247 100644--- a/products/batch_exports/backend/activity_logging.py+++ b/products/batch_exports/backend/activity_logging.py@@ -42,16 +42,16 @@ def handle_batch_export_change(returndestination_type = get_batch_export_destination_type(batch_export)- created_by_user_id, created_by_user_email, created_by_user_name = get_batch_export_created_by_info(batch_export)+ created_by = get_batch_export_created_by_info(batch_export)detail_name = get_batch_export_detail_name(batch_export, destination_type)context = BatchExportContext(name=batch_export.name or "Unnamed Export",destination_type=destination_type,interval=batch_export.interval or "",- created_by_user_id=created_by_user_id,- created_by_user_email=created_by_user_email,- created_by_user_name=created_by_user_name,+ created_by_user_id=created_by.user_id,+ created_by_user_email=created_by.email,+ created_by_user_name=created_by.name,)log_activity(diff --git a/products/warehouse_sources/backend/activity_logging.py b/products/warehouse_sources/backend/activity_logging.pyindex eb9d21da5eb0..ae61f775d1b3 100644--- a/products/warehouse_sources/backend/activity_logging.py+++ b/products/warehouse_sources/backend/activity_logging.py@@ -92,18 +92,16 @@ def handle_external_data_source_change(if not external_data_source:return- created_by_user_id, created_by_user_email, created_by_user_name = get_external_data_source_created_by_info(- external_data_source- )+ created_by = get_external_data_source_created_by_info(external_data_source)detail_name = get_external_data_source_detail_name(external_data_source)context = ExternalDataSourceContext(source_type=external_data_source.source_type or "",prefix=external_data_source.prefix,description=external_data_source.description,- created_by_user_id=created_by_user_id,- created_by_user_email=created_by_user_email,- created_by_user_name=created_by_user_name,+ created_by_user_id=created_by.user_id,+ created_by_user_email=created_by.email,+ created_by_user_name=created_by.name,)log_activity(