Skip to content

Commit 3a83154

Browse files
authored
Enforce function definition limits (#86)
1 parent d66632f commit 3a83154

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

singlestoredb/apps/_python_udfs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
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
18+
1619

1720
async def run_udf_app(
1821
log_level: str = 'error',
@@ -46,6 +49,13 @@ async def run_udf_app(
4649
udf_suffix = '_test'
4750
app = Application(url=base_url, app_mode='managed', name_suffix=udf_suffix)
4851

52+
if not app.endpoints:
53+
raise ValueError('You must define at least one function.')
54+
if len(app.endpoints) > MAX_UDFS_LIMIT:
55+
raise ValueError(
56+
f'You can only define a maximum of {MAX_UDFS_LIMIT} functions.',
57+
)
58+
4959
config = uvicorn.Config(
5060
app,
5161
host='0.0.0.0',

0 commit comments

Comments
 (0)