Skip to content

Commit b1c57da

Browse files
authored
Improve the Local Baserow single row service's error handling. (baserow#4530)
* Improve the GetRow service's error handling, instead of raising DoesNotExist, use ServiceImproperlyConfiguredDispatchException like other services. * Lint fix
1 parent 5d3c90f commit b1c57da

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

backend/src/baserow/contrib/integrations/local_baserow/service_types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from django.db import transaction
1919
from django.db.models import QuerySet
2020
from django.dispatch import Signal
21+
from django.utils.translation import gettext as _
2122

2223
from rest_framework import serializers
2324
from rest_framework.exceptions import ValidationError as DRFValidationError
@@ -1656,6 +1657,7 @@ def dispatch_data(
16561657
:param resolved_values: If the service has any formulas, this dictionary will
16571658
contain their resolved values.
16581659
:param dispatch_context: The context used for the dispatch.
1660+
:raises ServiceImproperlyConfiguredDispatchException: When no rows are found.
16591661
:return: The rows.
16601662
"""
16611663

@@ -1671,7 +1673,7 @@ def dispatch_data(
16711673
# row by setting the right condition
16721674
if "row_id" not in resolved_values:
16731675
if not queryset.exists():
1674-
raise DoesNotExist()
1676+
raise ServiceImproperlyConfiguredDispatchException(_("No rows found"))
16751677
return {
16761678
"data": queryset.first(),
16771679
"baserow_table_model": table_model,
@@ -1686,7 +1688,9 @@ def dispatch_data(
16861688
"public_allowed_properties": only_field_names,
16871689
}
16881690
except table_model.DoesNotExist:
1689-
raise DoesNotExist()
1691+
raise ServiceImproperlyConfiguredDispatchException(
1692+
_(f"Row {resolved_values['row_id']} does not exist.")
1693+
)
16901694

16911695
def dispatch_transform(self, dispatch_data: Dict[str, Any]) -> DispatchResult:
16921696
"""

backend/src/baserow/locale/en/LC_MESSAGES/django.po

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-11-17 15:17+0000\n"
11+
"POT-Creation-Date: 2026-01-09 16:13+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -35,15 +35,15 @@ msgstr ""
3535
#: src/baserow/contrib/automation/action_scopes.py:14
3636
#, python-format
3737
msgid ""
38-
"of type (%(node_type)s) in automation \"%(automation_name)s\" "
39-
"(%(automation_id)s)."
38+
"of type (%(node_type)s) in automation "
39+
"\"%(automation_name)s\" (%(automation_id)s)."
4040
msgstr ""
4141

4242
#: src/baserow/contrib/automation/actions.py:8
4343
#, python-format
4444
msgid ""
45-
"in workflow (%(workflow_id)s) in automation \"%(automation_name)s\" "
46-
"(%(automation_id)s)."
45+
"in workflow (%(workflow_id)s) in automation "
46+
"\"%(automation_name)s\" (%(automation_id)s)."
4747
msgstr ""
4848

4949
#: src/baserow/contrib/automation/automation_init_application.py:29
@@ -221,6 +221,14 @@ msgstr ""
221221
msgid "Triggered at"
222222
msgstr ""
223223

224+
#: src/baserow/contrib/integrations/local_baserow/service_types.py:1676
225+
msgid "No rows found"
226+
msgstr ""
227+
228+
#: src/baserow/contrib/integrations/local_baserow/service_types.py:1692
229+
msgid "Row {resolved_values['row_id']} does not exist."
230+
msgstr ""
231+
224232
#: src/baserow/contrib/integrations/slack/service_types.py:166
225233
msgid "OK"
226234
msgstr ""

backend/tests/baserow/contrib/integrations/local_baserow/service_types/test_get_row_service_type.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
)
1717
from baserow.core.exceptions import PermissionException
1818
from baserow.core.services.exceptions import (
19-
DoesNotExist,
2019
InvalidContextContentDispatchException,
2120
ServiceImproperlyConfiguredDispatchException,
2221
)
@@ -257,7 +256,7 @@ def test_local_baserow_get_row_service_dispatch_data_with_view_filter(data_fixtu
257256
dispatch_context = FakeDispatchContext()
258257

259258
dispatch_values = service_type.resolve_service_formulas(service, dispatch_context)
260-
with pytest.raises(DoesNotExist):
259+
with pytest.raises(ServiceImproperlyConfiguredDispatchException):
261260
service_type.dispatch_data(service, dispatch_values, dispatch_context)
262261

263262

@@ -291,7 +290,7 @@ def test_local_baserow_get_row_service_dispatch_data_with_service_search(
291290
dispatch_context = FakeDispatchContext()
292291

293292
dispatch_values = service_type.resolve_service_formulas(service, dispatch_context)
294-
with pytest.raises(DoesNotExist):
293+
with pytest.raises(ServiceImproperlyConfiguredDispatchException):
295294
service_type.dispatch_data(service, dispatch_values, dispatch_context)
296295

297296

@@ -422,7 +421,7 @@ def test_local_baserow_get_row_service_dispatch_data_row_not_exist(data_fixture)
422421

423422
dispatch_context = FakeDispatchContext()
424423
dispatch_values = service_type.resolve_service_formulas(service, dispatch_context)
425-
with pytest.raises(DoesNotExist):
424+
with pytest.raises(ServiceImproperlyConfiguredDispatchException):
426425
service_type.dispatch_data(service, dispatch_values, dispatch_context)
427426

428427

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "bug",
3+
"message": "Improved error handling in the Local Baserow single table row action.",
4+
"issue_origin": "github",
5+
"issue_number": null,
6+
"domain": "integration",
7+
"bullet_points": [],
8+
"created_at": "2026-01-09"
9+
}

0 commit comments

Comments
 (0)