Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend): Make sure all the obtained DB connections are able to query (#8894)

Zamil Majdye2904136bd91
diff --git a/autogpt_platform/backend/README.md b/autogpt_platform/backend/README.md
index ab91027df2..c76fe40ba4 100644
--- a/autogpt_platform/backend/README.md
+++ b/autogpt_platform/backend/README.md
@@ -200,4 +200,4 @@ To add a new agent block, you need to create a new class that inherits from `Blo
* `run` method: the main logic of the block.
* `test_input` & `test_output`: the sample input and output data for the block, which will be used to auto-test the block.
* You can mock the functions declared in the block using the `test_mock` field for your unit tests.
-* Once you finish creating the block, you can test it by running `pytest -s test/block/test_block.py`.
+* Once you finish creating the block, you can test it by running `poetry run pytest -s test/block/test_block.py`.
diff --git a/autogpt_platform/backend/backend/data/db.py b/autogpt_platform/backend/backend/data/db.py
index 4e1ee79737..d18942ccfa 100644
--- a/autogpt_platform/backend/backend/data/db.py
+++ b/autogpt_platform/backend/backend/data/db.py
@@ -29,6 +29,13 @@ async def connect():
if not prisma.is_connected():
raise ConnectionError("Failed to connect to Prisma.")
+ # Connection acquired from a pool like Supabase somehow still possibly allows
+ # the db client obtains a connection but still reject query connection afterward.
+ try:
+ await prisma.execute_raw("SELECT 1")
+ except Exception as e:
+ raise ConnectionError("Failed to connect to Prisma.") from e
+
@conn_retry("Prisma", "Releasing connection")
async def disconnect():