|
@@ -3,13 +3,15 @@ from rest_framework import serializers
|
|
|
from rest_framework.request import Request
|
|
|
from rest_framework.response import Response
|
|
|
|
|
|
+from sentry import features
|
|
|
from sentry.api.bases.project import ProjectEndpoint
|
|
|
from sentry.api.serializers import serialize
|
|
|
from sentry.models import ProjectOwnership
|
|
|
from sentry.ownership.grammar import CODEOWNERS, create_schema_from_issue_owners
|
|
|
from sentry.signals import ownership_rule_created
|
|
|
|
|
|
-MAX_RAW_LENGTH = 100000
|
|
|
+MAX_RAW_LENGTH = 100_000
|
|
|
+HIGHER_MAX_RAW_LENGTH = 200_000
|
|
|
|
|
|
|
|
|
class ProjectOwnershipSerializer(serializers.Serializer):
|
|
@@ -29,6 +31,13 @@ class ProjectOwnershipSerializer(serializers.Serializer):
|
|
|
{"raw": "Codeowner type paths can only be added by importing CODEOWNER files"}
|
|
|
)
|
|
|
|
|
|
+ def get_max_length(self):
|
|
|
+ if features.has(
|
|
|
+ "organizations:higher-ownership-limit", self.context["ownership"].project.organization
|
|
|
+ ):
|
|
|
+ return HIGHER_MAX_RAW_LENGTH
|
|
|
+ return MAX_RAW_LENGTH
|
|
|
+
|
|
|
def validate(self, attrs):
|
|
|
if "raw" not in attrs:
|
|
|
return attrs
|
|
@@ -37,9 +46,10 @@ class ProjectOwnershipSerializer(serializers.Serializer):
|
|
|
# that are several megabytes large. To not break this functionality for existing customers
|
|
|
# we temporarily allow rows that already exceed this limit to still be updated.
|
|
|
existing_raw = self.context["ownership"].raw or ""
|
|
|
- if len(attrs["raw"]) > MAX_RAW_LENGTH and len(existing_raw) <= MAX_RAW_LENGTH:
|
|
|
+ max_length = self.get_max_length()
|
|
|
+ if len(attrs["raw"]) > max_length and len(existing_raw) <= max_length:
|
|
|
raise serializers.ValidationError(
|
|
|
- {"raw": f"Raw needs to be <= {MAX_RAW_LENGTH} characters in length"}
|
|
|
+ {"raw": f"Raw needs to be <= {max_length} characters in length"}
|
|
|
)
|
|
|
|
|
|
schema = create_schema_from_issue_owners(attrs["raw"], self.context["ownership"].project_id)
|