Skip to content

Commit 95fb63f

Browse files
authored
Fix a hard-crash when querying custom code endpoint with invalid builder ID. (baserow#4964)
1 parent 33a6d46 commit 95fb63f

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed
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 a crash when fetching custom code for a non-existent builder ID.",
4+
"issue_origin": "github",
5+
"issue_number": null,
6+
"domain": "builder",
7+
"bullet_points": [],
8+
"created_at": "2026-03-12"
9+
}

enterprise/backend/src/baserow_enterprise/api/builder/custom_code/views.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from rest_framework.permissions import AllowAny
66
from rest_framework.views import APIView
77

8+
from baserow.api.applications.errors import ERROR_APPLICATION_DOES_NOT_EXIST
89
from baserow.api.decorators import map_exceptions
910
from baserow.api.schemas import get_error_schema
10-
from baserow.contrib.builder.errors import ERROR_BUILDER_DOES_NOT_EXIST
11-
from baserow.contrib.builder.exceptions import BuilderDoesNotExist
1211
from baserow.contrib.builder.service import BuilderService
12+
from baserow.core.exceptions import ApplicationDoesNotExist
1313
from baserow_enterprise.api.authentication import (
1414
AuthenticateFromUserSessionAuthentication,
1515
)
@@ -46,12 +46,16 @@ class PublicCustomCodeView(APIView):
4646
description=("Returns the css/js for the given builder."),
4747
responses={
4848
200: str,
49-
404: get_error_schema(["ERROR_BUILDER_DOES_NOT_EXIST"]),
49+
404: get_error_schema(
50+
[
51+
"ERROR_APPLICATION_DOES_NOT_EXIST",
52+
]
53+
),
5054
},
5155
)
5256
@map_exceptions(
5357
{
54-
BuilderDoesNotExist: ERROR_BUILDER_DOES_NOT_EXIST,
58+
ApplicationDoesNotExist: ERROR_APPLICATION_DOES_NOT_EXIST,
5559
}
5660
)
5761
def get(self, request, builder_id, code_type):

enterprise/backend/tests/baserow_enterprise_tests/builder/custom_code/test_enterprise_application_views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,17 @@ def test_get_enterprise_builder_custom_code_public_no_licence(api_client, data_f
263263
url,
264264
)
265265
assert response.status_code == HTTP_404_NOT_FOUND
266+
267+
268+
@pytest.mark.django_db
269+
def test_get_enterprise_builder_custom_code_public_application_not_found(
270+
enable_enterprise, api_client, data_fixture
271+
):
272+
url = reverse(
273+
"api:enterprise:custom_code:public_js",
274+
kwargs={"builder_id": 123456},
275+
)
276+
277+
response = api_client.get(url)
278+
279+
assert response.status_code == HTTP_404_NOT_FOUND

0 commit comments

Comments
 (0)