diff --git a/src/sentry/api/serializers/models/activity.py b/src/sentry/api/serializers/models/activity.py index 081ea1a5503107..2a429113ca5a7a 100644 --- a/src/sentry/api/serializers/models/activity.py +++ b/src/sentry/api/serializers/models/activity.py @@ -14,7 +14,7 @@ class ActivitySerializer(Serializer): def __init__(self, environment_func=None): self.environment_func = environment_func - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): # TODO(dcramer); assert on relations user_ids = [i.user_id for i in item_list if i.user_id] user_list = user_service.serialize_many( @@ -93,7 +93,7 @@ def get_attrs(self, item_list, user): for item in item_list } - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): if obj.type == ActivityType.SET_RESOLVED_IN_COMMIT.value: data = {"commit": attrs["commit"]} elif obj.type == ActivityType.SET_RESOLVED_IN_PULL_REQUEST.value: @@ -120,7 +120,7 @@ def serialize(self, obj, attrs, user): class OrganizationActivitySerializer(ActivitySerializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): from sentry.api.serializers import GroupSerializer # TODO(dcramer); assert on relations @@ -142,7 +142,7 @@ def get_attrs(self, item_list, user): attrs[item]["project"] = projects[str(item.project_id)] return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): context = super().serialize(obj, attrs, user) context["issue"] = attrs["issue"] context["project"] = attrs["project"] diff --git a/src/sentry/api/serializers/models/apiapplication.py b/src/sentry/api/serializers/models/apiapplication.py index 3812230a183ac2..d1cdcbbbb8e213 100644 --- a/src/sentry/api/serializers/models/apiapplication.py +++ b/src/sentry/api/serializers/models/apiapplication.py @@ -8,7 +8,7 @@ @register(ApiApplication) class ApiApplicationSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): is_secret_visible = obj.date_added > timezone.now() - timedelta(days=1) return { "id": obj.client_id, diff --git a/src/sentry/api/serializers/models/apiauthorization.py b/src/sentry/api/serializers/models/apiauthorization.py index 3bfc14e6688756..9c3d9b795a9329 100644 --- a/src/sentry/api/serializers/models/apiauthorization.py +++ b/src/sentry/api/serializers/models/apiauthorization.py @@ -4,7 +4,7 @@ @register(ApiAuthorization) class ApiAuthorizationSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): apps = { d["id"]: d for d in serialize({i.application for i in item_list if i.application_id}, user) @@ -17,7 +17,7 @@ def get_attrs(self, item_list, user): } return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "scopes": obj.get_scopes(), diff --git a/src/sentry/api/serializers/models/apikey.py b/src/sentry/api/serializers/models/apikey.py index 4cab55216417a1..3ce8b16d98d593 100644 --- a/src/sentry/api/serializers/models/apikey.py +++ b/src/sentry/api/serializers/models/apikey.py @@ -4,7 +4,7 @@ @register(ApiKey) class ApiKeySerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "label": obj.label, diff --git a/src/sentry/api/serializers/models/artifactbundle.py b/src/sentry/api/serializers/models/artifactbundle.py index 7eb3e78d18a036..de10b5d45aece1 100644 --- a/src/sentry/api/serializers/models/artifactbundle.py +++ b/src/sentry/api/serializers/models/artifactbundle.py @@ -22,7 +22,7 @@ def _compute_associations(item, grouped_bundles): def _format_date(date): return None if date is None else date.isoformat()[:19] + "Z" - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): # We sort by id, since it's the best (already existing) field to define total order of # release associations that is somehow consistent with upload sequence. release_artifact_bundles = ReleaseArtifactBundle.objects.filter( @@ -45,7 +45,7 @@ def get_attrs(self, item_list, user): for item in item_list } - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "bundleId": str(attrs["bundle_id"]), "associations": attrs["associations"], @@ -60,7 +60,7 @@ def __init__(self, archive, *args, **kwargs): Serializer.__init__(self, *args, **kwargs) self.archive = archive - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): return {item: self._compute_attrs(item) for item in item_list} def _compute_attrs(self, item): @@ -80,7 +80,7 @@ def _compute_attrs(self, item): "sourcemap": sourcemap, } - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": base64.urlsafe_b64encode(attrs["file_path"].encode()).decode(), # In case the file type string was invalid, we return the sentinel value INVALID_SOURCE_FILE_TYPE. diff --git a/src/sentry/api/serializers/models/auditlogentry.py b/src/sentry/api/serializers/models/auditlogentry.py index bb1b4f1c547218..6282c77a8c76bd 100644 --- a/src/sentry/api/serializers/models/auditlogentry.py +++ b/src/sentry/api/serializers/models/auditlogentry.py @@ -33,7 +33,7 @@ def override_actor_id(user): @register(AuditLogEntry) class AuditLogEntrySerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): # TODO(dcramer); assert on relations prefetch_related_objects(item_list, "actor") prefetch_related_objects(item_list, "target_user") @@ -57,7 +57,7 @@ def get_attrs(self, item_list, user): for item in item_list } - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): audit_log_event = audit_log.get(obj.event) try: diff --git a/src/sentry/api/serializers/models/authenticator.py b/src/sentry/api/serializers/models/authenticator.py index 79913110c7c409..02108c8b7a436c 100644 --- a/src/sentry/api/serializers/models/authenticator.py +++ b/src/sentry/api/serializers/models/authenticator.py @@ -8,7 +8,7 @@ @register(AuthenticatorInterface) class AuthenticatorInterfaceSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): data = { "id": str(obj.interface_id), "name": obj.name, @@ -37,7 +37,7 @@ def serialize(self, obj, attrs, user): @register(SmsInterface) class SmsInterfaceSerializer(AuthenticatorInterfaceSerializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): data = super().serialize(obj, attrs, user) data["phone"] = obj.phone_number return data diff --git a/src/sentry/api/serializers/models/broadcast.py b/src/sentry/api/serializers/models/broadcast.py index 0a84c27f2e3a11..fcb53658159e7b 100644 --- a/src/sentry/api/serializers/models/broadcast.py +++ b/src/sentry/api/serializers/models/broadcast.py @@ -6,7 +6,7 @@ @register(Broadcast) class BroadcastSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): if not user.is_authenticated: seen = set() else: @@ -18,7 +18,7 @@ def get_attrs(self, item_list, user): return {item: {"seen": item.id in seen} for item in item_list} - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "message": obj.message, @@ -33,7 +33,7 @@ def serialize(self, obj, attrs, user): class AdminBroadcastSerializer(BroadcastSerializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): attrs = super().get_attrs(item_list, user) counts = dict( BroadcastSeen.objects.filter(broadcast__in=item_list) @@ -47,7 +47,7 @@ def get_attrs(self, item_list, user): attrs[item]["user_count"] = counts.get(item.id, 0) return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): context = super().serialize(obj, attrs, user) context["userCount"] = attrs["user_count"] return context diff --git a/src/sentry/api/serializers/models/commit.py b/src/sentry/api/serializers/models/commit.py index 695de8214ddd95..3b454020c4fca9 100644 --- a/src/sentry/api/serializers/models/commit.py +++ b/src/sentry/api/serializers/models/commit.py @@ -28,7 +28,7 @@ def __init__(self, exclude=None, include=None, type=None, *args, **kwargs): self.exclude = frozenset(exclude if exclude else ()) self.type = type or "" - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): if "author" not in self.exclude: users_by_author = get_users_for_commits(item_list, user) else: @@ -63,7 +63,7 @@ def get_attrs(self, item_list, user): return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): d = { "id": obj.key, "message": obj.message, @@ -85,7 +85,7 @@ def __init__(self, exclude=None, include=None, type=None, *args, **kwargs): self.exclude = frozenset(exclude if exclude else ()) self.type = type or "" - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): from sentry.models.releasecommit import ReleaseCommit attrs = super().get_attrs(item_list, user) @@ -99,7 +99,7 @@ def get_attrs(self, item_list, user): attrs[item]["releases"] = releases_by_commit[item.id] return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): data = super().serialize(obj, attrs, user) data["releases"] = [ { diff --git a/src/sentry/api/serializers/models/dashboard.py b/src/sentry/api/serializers/models/dashboard.py index 52c90df7b8e580..d90d01933b2aae 100644 --- a/src/sentry/api/serializers/models/dashboard.py +++ b/src/sentry/api/serializers/models/dashboard.py @@ -20,7 +20,7 @@ @register(DashboardWidget) class DashboardWidgetSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): result = {} data_sources = serialize( list( @@ -82,7 +82,7 @@ def serialize(self, obj, attrs, user, **kwargs): @register(DashboardWidgetQuery) class DashboardWidgetQuerySerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): result = {} stateful_extraction_version = ( @@ -122,7 +122,7 @@ def serialize(self, obj, attrs, user, **kwargs): class DashboardListSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): item_dict = {i.id: i for i in item_list} widgets = ( @@ -183,7 +183,7 @@ def serialize(self, obj, attrs, user, **kwargs): @register(Dashboard) class DashboardDetailsSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): result = {} widgets = serialize( diff --git a/src/sentry/api/serializers/models/debug_file.py b/src/sentry/api/serializers/models/debug_file.py index a13006371577d9..ec3d7ffc6a7050 100644 --- a/src/sentry/api/serializers/models/debug_file.py +++ b/src/sentry/api/serializers/models/debug_file.py @@ -4,7 +4,7 @@ @register(ProjectDebugFile) class DebugFileSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): d = { "id": str(obj.id), "uuid": obj.debug_id[:36], diff --git a/src/sentry/api/serializers/models/discoversavedquery.py b/src/sentry/api/serializers/models/discoversavedquery.py index a8477b92d97505..fd6f9cad4cf367 100644 --- a/src/sentry/api/serializers/models/discoversavedquery.py +++ b/src/sentry/api/serializers/models/discoversavedquery.py @@ -12,7 +12,7 @@ @register(DiscoverSavedQuery) class DiscoverSavedQuerySerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): result: DefaultDict[str, dict] = defaultdict(lambda: {"created_by": {}}) service_serialized = user_service.serialize_many( diff --git a/src/sentry/api/serializers/models/environment.py b/src/sentry/api/serializers/models/environment.py index ff244853685045..f4a1bc9440e1b4 100644 --- a/src/sentry/api/serializers/models/environment.py +++ b/src/sentry/api/serializers/models/environment.py @@ -13,13 +13,13 @@ @register(Environment) class EnvironmentSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return {"id": str(obj.id), "name": obj.name} @register(EnvironmentProject) class EnvironmentProjectSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "name": obj.environment.name, @@ -38,7 +38,7 @@ def __init__(self, group, since=None, until=None): self.since = since self.until = until - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): attrs = {item: {"stats": {}} for item in item_list} items = {self.group.id: []} for item in item_list: @@ -67,7 +67,7 @@ def get_attrs(self, item_list, user): ] return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): result = super().serialize(obj, attrs, user) result["stats"] = attrs["stats"] return result diff --git a/src/sentry/api/serializers/models/event.py b/src/sentry/api/serializers/models/event.py index 2b351ee0209ecc..586a1c0016e51e 100644 --- a/src/sentry/api/serializers/models/event.py +++ b/src/sentry/api/serializers/models/event.py @@ -217,7 +217,7 @@ def should_display_error(self, error): and ".frames." not in name ) - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): from sentry.api.serializers.rest_framework import convert_dict_key_case, snake_to_camel_case errors = [ @@ -468,10 +468,10 @@ def serialize(self, obj, attrs, user, include_full_release_data=False): class SharedEventSerializer(EventSerializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): return super().get_attrs(item_list, user, is_public=True) - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): result = super().serialize(obj, attrs, user) del result["context"] del result["contexts"] @@ -497,7 +497,7 @@ class SimpleEventSerializer(EventSerializer): organization event search API gets real slow. """ - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): crash_files = get_crash_files(item_list) serialized_files = { file.event_id: serialized @@ -505,7 +505,7 @@ def get_attrs(self, item_list, user): } return {event: {"crash_file": serialized_files.get(event.event_id)} for event in item_list} - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): tags = [{"key": key.split("sentry:", 1)[-1], "value": value} for key, value in obj.tags] for tag in tags: query = convert_user_tag_to_query(tag["key"], tag["value"]) @@ -542,7 +542,7 @@ class ExternalEventSerializer(EventSerializer): should be used for Integrations that need to include event data. """ - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): from sentry.notifications.utils import get_notification_group_title tags = [{"key": key.split("sentry:", 1)[-1], "value": value} for key, value in obj.tags] diff --git a/src/sentry/api/serializers/models/eventattachment.py b/src/sentry/api/serializers/models/eventattachment.py index a3912c685e2c2f..7df11290ef632a 100644 --- a/src/sentry/api/serializers/models/eventattachment.py +++ b/src/sentry/api/serializers/models/eventattachment.py @@ -14,7 +14,7 @@ def get_attrs(self, item_list, user, **kwargs): } return {ea: {"file": files[ea.file_id]} for ea in item_list if ea.file_id} - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): file = attrs.get("file") content_type = obj.content_type or get_mimetype(file) size = obj.size if obj.size is not None else file.size diff --git a/src/sentry/api/serializers/models/eventuser.py b/src/sentry/api/serializers/models/eventuser.py index 8d483558439747..89328f031d77ca 100644 --- a/src/sentry/api/serializers/models/eventuser.py +++ b/src/sentry/api/serializers/models/eventuser.py @@ -5,7 +5,7 @@ @register(EventUser) class EventUserSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id) if obj.id is not None else obj.id, "tagValue": obj.tag_value, diff --git a/src/sentry/api/serializers/models/filechange.py b/src/sentry/api/serializers/models/filechange.py index 84998ed41ce93f..558692ed7ccbb1 100644 --- a/src/sentry/api/serializers/models/filechange.py +++ b/src/sentry/api/serializers/models/filechange.py @@ -11,7 +11,7 @@ @register(CommitFileChange) class CommitFileChangeSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): commits = list( Commit.objects.filter(id__in=[f.commit_id for f in item_list]).select_related("author") ) @@ -35,7 +35,7 @@ def get_attrs(self, item_list, user): return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "orgId": obj.organization_id, diff --git a/src/sentry/api/serializers/models/grouprelease.py b/src/sentry/api/serializers/models/grouprelease.py index 46d17e7ccaaf3b..95a90914378311 100644 --- a/src/sentry/api/serializers/models/grouprelease.py +++ b/src/sentry/api/serializers/models/grouprelease.py @@ -15,7 +15,7 @@ @register(GroupRelease) class GroupReleaseSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): release_list = list(Release.objects.filter(id__in=[i.release_id for i in item_list])) releases = {r.id: d for r, d in zip(release_list, serialize(release_list, user))} @@ -24,7 +24,7 @@ def get_attrs(self, item_list, user): result[item] = {"release": releases.get(item.release_id)} return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "release": attrs["release"], "environment": obj.environment, @@ -43,7 +43,7 @@ def __init__(self, since=None, until=None): self.since = since self.until = until - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): attrs = super().get_attrs(item_list, user) tenant_ids = ( @@ -85,7 +85,7 @@ def get_attrs(self, item_list, user): ] return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): result = super().serialize(obj, attrs, user) result["stats"] = attrs["stats"] return result diff --git a/src/sentry/api/serializers/models/groupseen.py b/src/sentry/api/serializers/models/groupseen.py index 5e7c4081cb51ea..859704f8c35e2e 100644 --- a/src/sentry/api/serializers/models/groupseen.py +++ b/src/sentry/api/serializers/models/groupseen.py @@ -5,7 +5,7 @@ @register(GroupSeen) class GroupSeenSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): serialized_users = user_service.serialize_many( filter=dict(user_ids=[i.user_id for i in item_list]), as_user=user ) @@ -22,7 +22,7 @@ def get_attrs(self, item_list, user): result[item] = {"user": user_map[user_id_str]} return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): data = attrs.get("user") if data is None: return None diff --git a/src/sentry/api/serializers/models/grouptombstone.py b/src/sentry/api/serializers/models/grouptombstone.py index 04c27afab61199..690a1e097b558c 100644 --- a/src/sentry/api/serializers/models/grouptombstone.py +++ b/src/sentry/api/serializers/models/grouptombstone.py @@ -6,7 +6,7 @@ @register(GroupTombstone) class GroupTombstoneSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): user_list = user_service.serialize_many( filter={"user_ids": [item.actor_id for item in item_list if item.actor_id is not None]} ) @@ -17,7 +17,7 @@ def get_attrs(self, item_list, user): attrs[item] = {"user": users.get(item.actor_id, {})} return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "level": LOG_LEVELS.get(obj.level, "unknown"), diff --git a/src/sentry/api/serializers/models/identity.py b/src/sentry/api/serializers/models/identity.py index 17d1146bec399e..792ab9aedd0554 100644 --- a/src/sentry/api/serializers/models/identity.py +++ b/src/sentry/api/serializers/models/identity.py @@ -4,7 +4,7 @@ @register(Identity) class IdentitySerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "identityProvider": serialize(obj.idp), diff --git a/src/sentry/api/serializers/models/identityprovider.py b/src/sentry/api/serializers/models/identityprovider.py index 50799ffd92d1ac..d9a01445962ac9 100644 --- a/src/sentry/api/serializers/models/identityprovider.py +++ b/src/sentry/api/serializers/models/identityprovider.py @@ -4,7 +4,7 @@ @register(IdentityProvider) class IdentityProviderSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "type": obj.type, diff --git a/src/sentry/api/serializers/models/incidentactivity.py b/src/sentry/api/serializers/models/incidentactivity.py index caba129849a29b..23bc6211586d1b 100644 --- a/src/sentry/api/serializers/models/incidentactivity.py +++ b/src/sentry/api/serializers/models/incidentactivity.py @@ -17,7 +17,7 @@ def get_attrs(self, item_list, user, **kwargs): user_lookup = {user["id"]: user for user in serialized_users} return {item: {"user": user_lookup.get(str(item.user_id))} for item in item_list} - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): incident = obj.incident return { diff --git a/src/sentry/api/serializers/models/incidentseen.py b/src/sentry/api/serializers/models/incidentseen.py index 5a3cc658b5ebf7..68f02b3b5632ba 100644 --- a/src/sentry/api/serializers/models/incidentseen.py +++ b/src/sentry/api/serializers/models/incidentseen.py @@ -6,7 +6,7 @@ @register(IncidentSeen) class IncidentSeenSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): item_users = user_service.serialize_many( filter={ "user_ids": [i.user_id for i in item_list], @@ -20,7 +20,7 @@ def get_attrs(self, item_list, user): result[item] = {"user": user_map[str(item.user_id)]} return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): data = attrs["user"] data["lastSeen"] = obj.last_seen return data diff --git a/src/sentry/api/serializers/models/metrics_blocking.py b/src/sentry/api/serializers/models/metrics_blocking.py index 73ade5b97cda50..b04aa29c416ed2 100644 --- a/src/sentry/api/serializers/models/metrics_blocking.py +++ b/src/sentry/api/serializers/models/metrics_blocking.py @@ -5,10 +5,10 @@ class MetricBlockingSerializer(Serializer): def __init__(self, *args, **kwargs): Serializer.__init__(self, *args, **kwargs) - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): return {item: item.__dict__ for item in item_list} - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "metricMri": attrs.get("metric_mri"), "isBlocked": attrs.get("is_blocked"), diff --git a/src/sentry/api/serializers/models/metrics_code_locations.py b/src/sentry/api/serializers/models/metrics_code_locations.py index 7d36b148be5b89..f87f3e75c7f4a5 100644 --- a/src/sentry/api/serializers/models/metrics_code_locations.py +++ b/src/sentry/api/serializers/models/metrics_code_locations.py @@ -13,7 +13,7 @@ def _compute_attrs(self, item): "frames": [location.__dict__ for location in item.frames], } - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): return {item: self._compute_attrs(item) for item in item_list} def _serialize_code_location_payload(self, code_location_payload): @@ -28,7 +28,7 @@ def _serialize_code_location_payload(self, code_location_payload): "postContext": code_location_payload.get("post_context"), } - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "projectId": attrs["project_id"], "mri": attrs["mri"], diff --git a/src/sentry/api/serializers/models/metrics_extraction_rules.py b/src/sentry/api/serializers/models/metrics_extraction_rules.py index c95da91e5e11d8..cafa3092d869db 100644 --- a/src/sentry/api/serializers/models/metrics_extraction_rules.py +++ b/src/sentry/api/serializers/models/metrics_extraction_rules.py @@ -8,7 +8,7 @@ class MetricsExtractionRuleSerializer(Serializer): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "spanAttribute": attrs.get("span_attribute"), "type": attrs.get("type"), @@ -23,7 +23,7 @@ class SpanAttributeExtractionRuleConfigSerializer(Serializer): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "spanAttribute": obj.span_attribute, "aggregates": list(obj.aggregates), diff --git a/src/sentry/api/serializers/models/organization_access_request.py b/src/sentry/api/serializers/models/organization_access_request.py index 2148106b4e564a..0e5587d295465c 100644 --- a/src/sentry/api/serializers/models/organization_access_request.py +++ b/src/sentry/api/serializers/models/organization_access_request.py @@ -5,7 +5,7 @@ @register(OrganizationAccessRequest) class OrganizationAccessRequestSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): serialized_user = None if obj.requester_id: serialized_users = user_service.serialize_many(filter=dict(user_ids=[obj.requester_id])) diff --git a/src/sentry/api/serializers/models/organization_plugin.py b/src/sentry/api/serializers/models/organization_plugin.py index 12b2b112d98d27..d0680f9746f3ba 100644 --- a/src/sentry/api/serializers/models/organization_plugin.py +++ b/src/sentry/api/serializers/models/organization_plugin.py @@ -2,7 +2,7 @@ class OrganizationPluginSerializer(PluginSerializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): data = super().serialize(obj, attrs, user) data["project"] = {"id": self.project.id, "slug": self.project.slug} return data diff --git a/src/sentry/api/serializers/models/orgauthtoken.py b/src/sentry/api/serializers/models/orgauthtoken.py index 95c1d62b18678e..ddda66eacf72f5 100644 --- a/src/sentry/api/serializers/models/orgauthtoken.py +++ b/src/sentry/api/serializers/models/orgauthtoken.py @@ -4,7 +4,8 @@ @register(OrgAuthToken) class OrgAuthTokenSerializer(Serializer): - def serialize(self, obj, attrs, user, token): + def serialize(self, obj, attrs, user, **kwargs): + token = kwargs["token"] data = { "id": str(obj.id), "name": obj.name, diff --git a/src/sentry/api/serializers/models/platformexternalissue.py b/src/sentry/api/serializers/models/platformexternalissue.py index 0fe86c43b72739..109a4cc9002520 100644 --- a/src/sentry/api/serializers/models/platformexternalissue.py +++ b/src/sentry/api/serializers/models/platformexternalissue.py @@ -4,7 +4,7 @@ @register(PlatformExternalIssue) class PlatformExternalIssueSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "issueId": str(obj.group_id), diff --git a/src/sentry/api/serializers/models/plugin.py b/src/sentry/api/serializers/models/plugin.py index 19aa913016dc6c..eae0d293327ea8 100644 --- a/src/sentry/api/serializers/models/plugin.py +++ b/src/sentry/api/serializers/models/plugin.py @@ -36,7 +36,7 @@ class PluginSerializer(Serializer): def __init__(self, project=None): self.project = project - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): from sentry.api.endpoints.project_releases_token import _get_webhook_url doc = "" @@ -132,7 +132,7 @@ def get_attrs(self, item_list, user, **kwargs): for item in item_list } - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): d = super().serialize(obj, attrs, user) d["config"] = attrs.get("config") return d diff --git a/src/sentry/api/serializers/models/project.py b/src/sentry/api/serializers/models/project.py index dc965b463e75f1..1c608cf8e88c1b 100644 --- a/src/sentry/api/serializers/models/project.py +++ b/src/sentry/api/serializers/models/project.py @@ -556,7 +556,7 @@ def get_attrs( attrs[item]["organization"] = orgs[str(item.organization_id)] return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): data = super().serialize(obj, attrs, user) data["organization"] = attrs["organization"] return data @@ -1128,7 +1128,7 @@ def get_value_with_default(self, attrs, key): class SharedProjectSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): from sentry import features feature_list = [] diff --git a/src/sentry/api/serializers/models/project_platform.py b/src/sentry/api/serializers/models/project_platform.py index 76e548989913a9..33dd8c50993041 100644 --- a/src/sentry/api/serializers/models/project_platform.py +++ b/src/sentry/api/serializers/models/project_platform.py @@ -10,5 +10,5 @@ class ProjectPlatformSerializer(Serializer): Note: This model is used solely for analytics. """ - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return {"platform": obj.platform, "dateCreated": obj.date_added} diff --git a/src/sentry/api/serializers/models/project_transaction_threshold.py b/src/sentry/api/serializers/models/project_transaction_threshold.py index 5b6be1219774fb..16196e8b7cf45f 100644 --- a/src/sentry/api/serializers/models/project_transaction_threshold.py +++ b/src/sentry/api/serializers/models/project_transaction_threshold.py @@ -8,7 +8,7 @@ @register(ProjectTransactionThreshold) class ProjectTransactionThresholdSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "threshold": str(obj.threshold), @@ -22,7 +22,7 @@ def serialize(self, obj, attrs, user): @register(ProjectTransactionThresholdOverride) class ProjectTransactionThresholdOverrideSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "threshold": str(obj.threshold), diff --git a/src/sentry/api/serializers/models/projectcodeowners.py b/src/sentry/api/serializers/models/projectcodeowners.py index 3eeca3fb8152f1..4f78e1742cae05 100644 --- a/src/sentry/api/serializers/models/projectcodeowners.py +++ b/src/sentry/api/serializers/models/projectcodeowners.py @@ -73,7 +73,7 @@ def rename_schema_identifier_for_parsing(self, schema: dict[str, Any]) -> None: for rule_owner in rule["owners"]: rule_owner["name"] = rule_owner.pop("identifier") - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): from sentry.api.validators.project_codeowners import validate_codeowners_associations data = { diff --git a/src/sentry/api/serializers/models/pullrequest.py b/src/sentry/api/serializers/models/pullrequest.py index afb5cdddca6c94..b2fb3bb2da27a9 100644 --- a/src/sentry/api/serializers/models/pullrequest.py +++ b/src/sentry/api/serializers/models/pullrequest.py @@ -19,7 +19,7 @@ def get_users_for_pull_requests(item_list, user=None): @register(PullRequest) class PullRequestSerializer(Serializer): - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): users_by_author = get_users_for_pull_requests(item_list, user) repositories = list(Repository.objects.filter(id__in=[c.repository_id for c in item_list])) repository_map = {repository.id: repository for repository in repositories} @@ -39,7 +39,7 @@ def get_attrs(self, item_list, user): return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": obj.key, "title": obj.title, diff --git a/src/sentry/api/serializers/models/recentsearch.py b/src/sentry/api/serializers/models/recentsearch.py index 1175a4881aa4a3..e008a18d9aba96 100644 --- a/src/sentry/api/serializers/models/recentsearch.py +++ b/src/sentry/api/serializers/models/recentsearch.py @@ -4,7 +4,7 @@ @register(RecentSearch) class RecentSearchSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "organizationId": str(obj.organization_id), diff --git a/src/sentry/api/serializers/models/relay.py b/src/sentry/api/serializers/models/relay.py index 2b3371f915052c..d78f369d727bd3 100644 --- a/src/sentry/api/serializers/models/relay.py +++ b/src/sentry/api/serializers/models/relay.py @@ -14,7 +14,7 @@ class OrganizationRelayResponse(TypedDict): @register(Relay) class RelaySerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "relayId": str(obj.relay_id), "version": str(obj.version), diff --git a/src/sentry/api/serializers/models/relayusage.py b/src/sentry/api/serializers/models/relayusage.py index d68aa18bcaa7ae..ce5ca7ee639f25 100644 --- a/src/sentry/api/serializers/models/relayusage.py +++ b/src/sentry/api/serializers/models/relayusage.py @@ -4,7 +4,7 @@ @register(RelayUsage) class RelayUsageSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "relayId": obj.relay_id, "version": obj.version, diff --git a/src/sentry/api/serializers/models/release_file.py b/src/sentry/api/serializers/models/release_file.py index cd2e2dfe26576a..609b600682fa90 100644 --- a/src/sentry/api/serializers/models/release_file.py +++ b/src/sentry/api/serializers/models/release_file.py @@ -35,7 +35,7 @@ def decode_release_file_id(id: str): @register(ReleaseFile) class ReleaseFileSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): dist_name = None if obj.dist_id: dist_name = Distribution.objects.get(pk=obj.dist_id).name diff --git a/src/sentry/api/serializers/models/release_threshold.py b/src/sentry/api/serializers/models/release_threshold.py index 071d49242a5c4a..45e28d090b58a0 100644 --- a/src/sentry/api/serializers/models/release_threshold.py +++ b/src/sentry/api/serializers/models/release_threshold.py @@ -8,7 +8,7 @@ @register(ReleaseThreshold) class ReleaseThresholdSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "threshold_type": THRESHOLD_TYPE_INT_TO_STR[obj.threshold_type], diff --git a/src/sentry/api/serializers/models/repository.py b/src/sentry/api/serializers/models/repository.py index d8ce1d43a33199..beb90097d587a9 100644 --- a/src/sentry/api/serializers/models/repository.py +++ b/src/sentry/api/serializers/models/repository.py @@ -4,7 +4,7 @@ @register(Repository) class RepositorySerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): external_slug = None integration_id = None if obj.integration_id: diff --git a/src/sentry/api/serializers/models/repository_project_path_config.py b/src/sentry/api/serializers/models/repository_project_path_config.py index 1a60d56e259d78..c54647a7171b7d 100644 --- a/src/sentry/api/serializers/models/repository_project_path_config.py +++ b/src/sentry/api/serializers/models/repository_project_path_config.py @@ -6,7 +6,7 @@ @register(RepositoryProjectPathConfig) class RepositoryProjectPathConfigSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): integration = None if obj.organization_integration_id: integration = integration_service.get_integration( diff --git a/src/sentry/api/serializers/models/savedsearch.py b/src/sentry/api/serializers/models/savedsearch.py index 24ecd9878e7d40..50a28ed47c7d5c 100644 --- a/src/sentry/api/serializers/models/savedsearch.py +++ b/src/sentry/api/serializers/models/savedsearch.py @@ -4,7 +4,7 @@ @register(SavedSearch) class SavedSearchSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "type": obj.type, diff --git a/src/sentry/api/serializers/models/sentry_app_component.py b/src/sentry/api/serializers/models/sentry_app_component.py index ce8cf6fe8c112a..55cb11d2e4d89e 100644 --- a/src/sentry/api/serializers/models/sentry_app_component.py +++ b/src/sentry/api/serializers/models/sentry_app_component.py @@ -8,7 +8,8 @@ @register(SentryAppComponent) class SentryAppComponentSerializer(Serializer): - def serialize(self, obj, attrs, user, errors): + def serialize(self, obj, attrs, user, **kwargs): + errors = kwargs["errors"] return { "uuid": str(obj.uuid), "type": obj.type, diff --git a/src/sentry/api/serializers/models/sentry_app_installation.py b/src/sentry/api/serializers/models/sentry_app_installation.py index 9f71348f2c1a75..58b04f797d9c53 100644 --- a/src/sentry/api/serializers/models/sentry_app_installation.py +++ b/src/sentry/api/serializers/models/sentry_app_installation.py @@ -36,15 +36,16 @@ def get_attrs( } return result - def serialize(self, install, attrs, user, access=None): + def serialize(self, obj, attrs, user, **kwargs): + access = kwargs.get("access") data = { "app": {"uuid": attrs["sentry_app"].uuid, "slug": attrs["sentry_app"].slug}, "organization": {"slug": attrs["organization"].slug}, - "uuid": install.uuid, - "status": SentryAppInstallationStatus.as_str(install.status), + "uuid": obj.uuid, + "status": SentryAppInstallationStatus.as_str(obj.status), } - if install.api_grant and access and access.has_scope("org:integrations"): - data["code"] = install.api_grant.code + if obj.api_grant and access and access.has_scope("org:integrations"): + data["code"] = obj.api_grant.code return data diff --git a/src/sentry/api/serializers/models/servicehook.py b/src/sentry/api/serializers/models/servicehook.py index d8f5aa013839d5..290da2f54002e5 100644 --- a/src/sentry/api/serializers/models/servicehook.py +++ b/src/sentry/api/serializers/models/servicehook.py @@ -4,7 +4,7 @@ @register(ServiceHook) class ServiceHookSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": obj.guid, "url": obj.url, diff --git a/src/sentry/api/serializers/models/tagvalue.py b/src/sentry/api/serializers/models/tagvalue.py index fa69eb1fcd1f2e..66b050ff4d71b9 100644 --- a/src/sentry/api/serializers/models/tagvalue.py +++ b/src/sentry/api/serializers/models/tagvalue.py @@ -4,7 +4,7 @@ class EnvironmentTagValueSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return {"id": str(obj.id), "name": obj.value} @@ -12,14 +12,14 @@ class UserTagValueSerializer(Serializer): def __init__(self, project_id): self.project_id = project_id - def get_attrs(self, item_list, user): + def get_attrs(self, item_list, user, **kwargs): users = EventUser.for_tags(project_id=self.project_id, values=[t.value for t in item_list]) result = {} for item in item_list: result[item] = {"user": users.get(item.value)} return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): if isinstance(attrs["user"], EventUser): result = attrs["user"].serialize() else: diff --git a/src/sentry/api/serializers/models/user_social_auth.py b/src/sentry/api/serializers/models/user_social_auth.py index c5a6cd9d2f9cc7..abd4b35804c5da 100644 --- a/src/sentry/api/serializers/models/user_social_auth.py +++ b/src/sentry/api/serializers/models/user_social_auth.py @@ -10,7 +10,7 @@ def get_provider_label(obj: UserSocialAuth) -> str: @register(UserSocialAuth) class UserSocialAuthSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "provider": obj.provider, diff --git a/src/sentry/api/serializers/models/useremail.py b/src/sentry/api/serializers/models/useremail.py index 087b36745aae1a..ed965cd2cd5b36 100644 --- a/src/sentry/api/serializers/models/useremail.py +++ b/src/sentry/api/serializers/models/useremail.py @@ -4,7 +4,7 @@ @register(UserEmail) class UserEmailSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): primary_email = UserEmail.objects.get_primary_email(user) return { "email": obj.email, diff --git a/src/sentry/api/serializers/models/userip.py b/src/sentry/api/serializers/models/userip.py index f765cae6da2487..5a1e04a1ee102f 100644 --- a/src/sentry/api/serializers/models/userip.py +++ b/src/sentry/api/serializers/models/userip.py @@ -4,7 +4,7 @@ @register(UserIP) class UserIPSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "ipAddress": obj.ip_address, diff --git a/src/sentry/api/serializers/models/userreport.py b/src/sentry/api/serializers/models/userreport.py index 85be18bd7c0b15..6ec62d5051a79e 100644 --- a/src/sentry/api/serializers/models/userreport.py +++ b/src/sentry/api/serializers/models/userreport.py @@ -86,7 +86,7 @@ def get_attrs(self, item_list, user, **kwargs): ) return attrs - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): context = super().serialize(obj, attrs, user) context["issue"] = attrs["group"] return context diff --git a/src/sentry/api/serializers/models/userrole.py b/src/sentry/api/serializers/models/userrole.py index 8d27330b90e68c..ec886df41d15cb 100644 --- a/src/sentry/api/serializers/models/userrole.py +++ b/src/sentry/api/serializers/models/userrole.py @@ -4,7 +4,7 @@ @register(UserRole) class UserRoleSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "id": str(obj.id), "name": obj.name, diff --git a/src/sentry/incidents/endpoints/serializers/incident.py b/src/sentry/incidents/endpoints/serializers/incident.py index ba7c3971c75505..c2ad42429c2936 100644 --- a/src/sentry/incidents/endpoints/serializers/incident.py +++ b/src/sentry/incidents/endpoints/serializers/incident.py @@ -72,7 +72,7 @@ def get_attrs(self, item_list, user, **kwargs): return results - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): date_closed = obj.date_closed.replace(second=0, microsecond=0) if obj.date_closed else None return { "id": str(obj.id), @@ -119,7 +119,7 @@ def get_attrs(self, item_list, user, **kwargs): results[item]["is_subscribed"] = item.id in subscribed_incidents return results - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): context = super().serialize(obj, attrs, user) context["isSubscribed"] = attrs["is_subscribed"] # The query we should use to get accurate results in Discover. diff --git a/src/sentry/incidents/endpoints/team_alerts_triggered.py b/src/sentry/incidents/endpoints/team_alerts_triggered.py index 1895eeeef96c8a..085c6289f14c92 100644 --- a/src/sentry/incidents/endpoints/team_alerts_triggered.py +++ b/src/sentry/incidents/endpoints/team_alerts_triggered.py @@ -119,7 +119,7 @@ def get_attrs(self, item_list, user, **kwargs): alert_rule_attrs["weekly_avg"] = alert_rule_counts.get(alert_rule.id, 0) / weeks return result - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): result = super().serialize(obj, attrs, user) result["weeklyAvg"] = attrs["weekly_avg"] result["totalThisWeek"] = obj.count diff --git a/src/sentry/replays/serializers.py b/src/sentry/replays/serializers.py index 49263d3cd9a9b2..d6093fefd268f6 100644 --- a/src/sentry/replays/serializers.py +++ b/src/sentry/replays/serializers.py @@ -2,7 +2,7 @@ class ReplayRecordingSegmentSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): return { "replayId": obj.replay_id, "segmentId": obj.segment_id, diff --git a/src/sentry/tagstore/types.py b/src/sentry/tagstore/types.py index c13c79a335ea9b..cf8ba94bac6e3c 100644 --- a/src/sentry/tagstore/types.py +++ b/src/sentry/tagstore/types.py @@ -94,7 +94,7 @@ def __init__(self, group_id, key, value, times_seen, first_seen, last_seen): @register(GroupTagKey) @register(TagKey) class TagKeySerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): from sentry import tagstore output = { @@ -113,7 +113,7 @@ def serialize(self, obj, attrs, user): @register(GroupTagValue) @register(TagValue) class TagValueSerializer(Serializer): - def serialize(self, obj, attrs, user): + def serialize(self, obj, attrs, user, **kwargs): from sentry import tagstore key = tagstore.get_standardized_key(obj.key)