Skip to content

Commit dfabb25

Browse files
authored
Fix throttling issue with preview actor (baserow#6078)
1 parent 1ea0d48 commit dfabb25

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

backend/src/baserow/contrib/builder/preview/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class BuilderPreviewActor:
4343

4444
is_authenticated = True
4545
is_anonymous = False
46+
is_staff = False
4647
user_source_authentication_header = "Authorization"
4748

4849
@property
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import pytest
2+
from rest_framework.request import Request
3+
from rest_framework.test import APIRequestFactory
4+
5+
from baserow.api.exceptions import ThrottledAPIException
6+
from baserow.contrib.builder.preview import BuilderPreviewActor
7+
from baserow.throttling.handler import ConcurrentUserRequestsThrottle
8+
9+
10+
def test_builder_preview_requests_are_throttled_and_release_their_slot(
11+
settings, monkeypatch
12+
):
13+
"""Preview actors obey the concurrency limit and free their slot after a response."""
14+
15+
settings.BASEROW_THROTTLE_BLACKLIST_TTL_SECONDS = 0
16+
monkeypatch.setattr(ConcurrentUserRequestsThrottle, "rate", 1, raising=False)
17+
actor = BuilderPreviewActor(
18+
builder_id=1, workspace_id=1, grant_id=12345, issued_by_user_id=1
19+
)
20+
request = Request(APIRequestFactory().get("/api/builder/preview/1/current/"))
21+
request.user = actor
22+
23+
throttle = ConcurrentUserRequestsThrottle()
24+
assert throttle.allow_request(request, None)
25+
try:
26+
with pytest.raises(ThrottledAPIException):
27+
ConcurrentUserRequestsThrottle().allow_request(request, None)
28+
finally:
29+
ConcurrentUserRequestsThrottle.on_request_processed(request._request)
30+
31+
assert ConcurrentUserRequestsThrottle().allow_request(request, None)
32+
ConcurrentUserRequestsThrottle.on_request_processed(request._request)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "bug",
3+
"message": "Fixed Application Builder previews failing when concurrent request throttling is enabled.",
4+
"issue_origin": "github",
5+
"issue_number": null,
6+
"domain": "builder",
7+
"bullet_points": [],
8+
"created_at": "2026-09-14"
9+
}

0 commit comments

Comments
 (0)