Skip to content

Commit 83a6683

Browse files
committed
Enforce function definition limits
1 parent d66632f commit 83a6683

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

singlestoredb/apps/_python_udfs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# Keep track of currently running server
1414
_running_server: 'typing.Optional[AwaitableUvicornServer]' = None
1515

16+
# Maximum number of UDFs allowed
17+
MAX_UDFS_LIMIT = 10
1618

1719
async def run_udf_app(
1820
log_level: str = 'error',
@@ -46,6 +48,11 @@ async def run_udf_app(
4648
udf_suffix = '_test'
4749
app = Application(url=base_url, app_mode='managed', name_suffix=udf_suffix)
4850

51+
if not app.endpoints:
52+
raise ValueError("You must define at least one function.")
53+
if len(app.endpoints) > MAX_UDFS_LIMIT:
54+
raise ValueError(f"You can only define a maximum of {MAX_UDFS_LIMIT} functions.")
55+
4956
config = uvicorn.Config(
5057
app,
5158
host='0.0.0.0',

0 commit comments

Comments
 (0)