Skip to content

Commit 4fd4174

Browse files
fix: move matches() check before weight guard in MovingWindowCallRatePolicy
Co-Authored-By: Daryna Ishchenko <darina.ishchenko17@gmail.com>
1 parent d8686b1 commit 4fd4174

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

airbyte_cdk/sources/streams/call_rate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,13 @@ def __init__(self, rates: list[Rate], matchers: list[RequestMatcher]):
447447
super().__init__(matchers=matchers)
448448

449449
def try_acquire(self, request: Any, weight: int) -> None:
450+
if not self.matches(request):
451+
raise ValueError("Request does not match the policy")
450452
lowest_limit = min(rate.limit for rate in self._bucket.rates)
451453
if weight > lowest_limit:
452454
raise ValueError(
453455
f"Weight can not exceed the lowest configured rate limit ({lowest_limit})"
454456
)
455-
if not self.matches(request):
456-
raise ValueError("Request does not match the policy")
457457

458458
try:
459459
self._limiter.try_acquire(request, weight=weight)

0 commit comments

Comments
 (0)