From 2577ecfbb4f1cb7adedb0e7be19c45033b08135c Mon Sep 17 00:00:00 2001
From: Peter Evans <peter@baserow.io>
Date: Tue, 7 Jan 2025 13:20:19 +0000
Subject: [PATCH] Resolve "Error thrown when the data source context loads, and
 one or more integrations have been deleted."

---
 ...solved_an_error_which_was_thrown_when_a_data_sourc.json | 7 +++++++
 web-frontend/modules/integrations/serviceTypes.js          | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 changelog/entries/unreleased/bug/3323_builder_resolved_an_error_which_was_thrown_when_a_data_sourc.json

diff --git a/changelog/entries/unreleased/bug/3323_builder_resolved_an_error_which_was_thrown_when_a_data_sourc.json b/changelog/entries/unreleased/bug/3323_builder_resolved_an_error_which_was_thrown_when_a_data_sourc.json
new file mode 100644
index 000000000..750ed15dd
--- /dev/null
+++ b/changelog/entries/unreleased/bug/3323_builder_resolved_an_error_which_was_thrown_when_a_data_sourc.json
@@ -0,0 +1,7 @@
+{
+    "type": "bug",
+    "message": "[Builder] Resolved an error which was thrown when a data source's integration was destroyed.",
+    "issue_number": 3323,
+    "bullet_points": [],
+    "created_at": "2024-12-30"
+}
\ No newline at end of file
diff --git a/web-frontend/modules/integrations/serviceTypes.js b/web-frontend/modules/integrations/serviceTypes.js
index d858af1a7..db346d642 100644
--- a/web-frontend/modules/integrations/serviceTypes.js
+++ b/web-frontend/modules/integrations/serviceTypes.js
@@ -55,7 +55,7 @@ export class LocalBaserowTableServiceType extends ServiceType {
       'integration/getIntegrationById'
     ](application, service.integration_id)
 
-    const databases = integration.context_data?.databases
+    const databases = integration?.context_data?.databases || []
 
     const tableSelected = databases
       .map((database) => database.tables)
@@ -268,7 +268,7 @@ export class LocalBaserowAggregateRowsServiceType extends LocalBaserowTableServi
       'integration/getIntegrationById'
     ](application, service.integration_id)
 
-    const databases = integration.context_data?.databases
+    const databases = integration?.context_data?.databases || []
 
     const tableSelected = databases
       .map((database) => database.tables)