From 83a66833f0e950776472f93894a3be7be3816a10 Mon Sep 17 00:00:00 2001 From: Prabhat Sachdeva Date: Mon, 11 Aug 2025 05:24:14 +0530 Subject: [PATCH 1/4] Enforce function definition limits --- singlestoredb/apps/_python_udfs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/singlestoredb/apps/_python_udfs.py b/singlestoredb/apps/_python_udfs.py index d7bca6d6b..7dc53438a 100644 --- a/singlestoredb/apps/_python_udfs.py +++ b/singlestoredb/apps/_python_udfs.py @@ -13,6 +13,8 @@ # Keep track of currently running server _running_server: 'typing.Optional[AwaitableUvicornServer]' = None +# Maximum number of UDFs allowed +MAX_UDFS_LIMIT = 10 async def run_udf_app( log_level: str = 'error', @@ -46,6 +48,11 @@ async def run_udf_app( udf_suffix = '_test' app = Application(url=base_url, app_mode='managed', name_suffix=udf_suffix) + if not app.endpoints: + raise ValueError("You must define at least one function.") + if len(app.endpoints) > MAX_UDFS_LIMIT: + raise ValueError(f"You can only define a maximum of {MAX_UDFS_LIMIT} functions.") + config = uvicorn.Config( app, host='0.0.0.0', From d40c7248d587b10598a433feb843c07de7001884 Mon Sep 17 00:00:00 2001 From: Prabhat Sachdeva Date: Mon, 11 Aug 2025 05:38:54 +0530 Subject: [PATCH 2/4] lint fix --- singlestoredb/apps/_python_udfs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/singlestoredb/apps/_python_udfs.py b/singlestoredb/apps/_python_udfs.py index 7dc53438a..b138e8c42 100644 --- a/singlestoredb/apps/_python_udfs.py +++ b/singlestoredb/apps/_python_udfs.py @@ -16,6 +16,7 @@ # Maximum number of UDFs allowed MAX_UDFS_LIMIT = 10 + async def run_udf_app( log_level: str = 'error', kill_existing_app_server: bool = True, @@ -51,7 +52,9 @@ async def run_udf_app( if not app.endpoints: raise ValueError("You must define at least one function.") if len(app.endpoints) > MAX_UDFS_LIMIT: - raise ValueError(f"You can only define a maximum of {MAX_UDFS_LIMIT} functions.") + raise ValueError( + f"You can only define a maximum of {MAX_UDFS_LIMIT} functions." + ) config = uvicorn.Config( app, From cfd1c9e20efb8c41a950b03c8e0757809cc06503 Mon Sep 17 00:00:00 2001 From: Prabhat Sachdeva Date: Mon, 11 Aug 2025 20:02:26 +0530 Subject: [PATCH 3/4] lint fix --- singlestoredb/apps/_python_udfs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/singlestoredb/apps/_python_udfs.py b/singlestoredb/apps/_python_udfs.py index b138e8c42..29065981c 100644 --- a/singlestoredb/apps/_python_udfs.py +++ b/singlestoredb/apps/_python_udfs.py @@ -50,10 +50,10 @@ async def run_udf_app( app = Application(url=base_url, app_mode='managed', name_suffix=udf_suffix) if not app.endpoints: - raise ValueError("You must define at least one function.") + raise ValueError('You must define at least one function.') if len(app.endpoints) > MAX_UDFS_LIMIT: raise ValueError( - f"You can only define a maximum of {MAX_UDFS_LIMIT} functions." + f"You can only define a maximum of {MAX_UDFS_LIMIT} functions.", ) config = uvicorn.Config( From adf5ffd4adb4647dbc5c90ae2792eac804ca19ec Mon Sep 17 00:00:00 2001 From: Prabhat Sachdeva Date: Mon, 11 Aug 2025 20:16:14 +0530 Subject: [PATCH 4/4] lint fix --- singlestoredb/apps/_python_udfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlestoredb/apps/_python_udfs.py b/singlestoredb/apps/_python_udfs.py index 29065981c..b94a4fdec 100644 --- a/singlestoredb/apps/_python_udfs.py +++ b/singlestoredb/apps/_python_udfs.py @@ -53,7 +53,7 @@ async def run_udf_app( raise ValueError('You must define at least one function.') if len(app.endpoints) > MAX_UDFS_LIMIT: raise ValueError( - f"You can only define a maximum of {MAX_UDFS_LIMIT} functions.", + f'You can only define a maximum of {MAX_UDFS_LIMIT} functions.', ) config = uvicorn.Config(