Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 3f74fa4

Browse files
committed
Add throttling for combined-upload
1 parent c5ce5d3 commit 3f74fa4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

upload/throttles.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.conf import settings
44
from django.core.exceptions import ObjectDoesNotExist
55
from django.db.models import Q
6+
from rest_framework.exceptions import ValidationError
67
from rest_framework.throttling import BaseThrottle
78
from shared.reports.enums import UploadType
89
from shared.upload.utils import query_monthly_coverage_measurements
@@ -38,7 +39,7 @@ def allow_request(self, request, view):
3839
)
3940
return False
4041
return True
41-
except ObjectDoesNotExist:
42+
except (ObjectDoesNotExist, ValidationError):
4243
return True
4344

4445

@@ -71,5 +72,5 @@ def allow_request(self, request, view):
7172
)
7273
return False
7374
return True
74-
except ObjectDoesNotExist:
75+
except (ObjectDoesNotExist, ValidationError):
7576
return True

upload/views/combined_upload.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
CommitSerializer,
2222
UploadSerializer,
2323
)
24+
from upload.throttles import UploadsPerCommitThrottle, UploadsPerWindowThrottle
2425
from upload.views.base import GetterMixin
2526
from upload.views.commits import CommitLogicMixin
2627
from upload.views.reports import ReportLogicMixin
@@ -41,6 +42,7 @@ class CombinedUploadView(
4142
RepositoryLegacyTokenAuthentication,
4243
TokenlessAuthentication,
4344
]
45+
throttle_classes = [UploadsPerCommitThrottle, UploadsPerWindowThrottle]
4446

4547
def get_exception_handler(self):
4648
return repo_auth_custom_exception_handler

0 commit comments

Comments
 (0)