2828 PYTHON_THREADPOOL_THREAD_COUNT_MAX_37 ,
2929 PYTHON_THREADPOOL_THREAD_COUNT_MIN ,
3030 PYTHON_ENABLE_DEBUG_LOGGING ,
31- SCRIPT_FILE_NAME ,
31+ PYTHON_SCRIPT_FILE_NAME ,
32+ PYTHON_SCRIPT_FILE_NAME_DEFAULT ,
3233 PYTHON_LANGUAGE_RUNTIME , CUSTOMER_PACKAGES_PATH )
3334from .extension import ExtensionManager
3435from .logging import disable_console_logging , enable_console_logging
3536from .logging import (logger , error_logger , is_system_log_category ,
3637 CONSOLE_LOG_PREFIX , format_exception )
3738from .utils .app_setting_manager import get_python_appsetting_state
38- from .utils .common import get_app_setting , is_envvar_true
39+ from .utils .common import (get_app_setting , is_envvar_true ,
40+ validate_script_file_name )
3941from .utils .dependency import DependencyManager
4042from .utils .tracing import marshall_exception_trace
4143from .utils .wrappers import disable_feature_by
@@ -327,24 +329,29 @@ async def _handle__worker_status_request(self, request):
327329 async def _handle__functions_metadata_request (self , request ):
328330 metadata_request = request .functions_metadata_request
329331 directory = metadata_request .function_app_directory
330- function_path = os .path .join (directory , SCRIPT_FILE_NAME )
332+ script_file_name = get_app_setting (
333+ setting = PYTHON_SCRIPT_FILE_NAME ,
334+ default_value = f'{ PYTHON_SCRIPT_FILE_NAME_DEFAULT } ' )
335+ function_path = os .path .join (directory , script_file_name )
331336
332337 logger .info (
333- 'Received WorkerMetadataRequest, request ID %s, directory: %s' ,
334- self .request_id , directory )
335-
336- if not os .path .exists (function_path ):
337- # Fallback to legacy model
338- logger .info ("%s does not exist. "
339- "Switching to host indexing." , SCRIPT_FILE_NAME )
340- return protos .StreamingMessage (
341- request_id = request .request_id ,
342- function_metadata_response = protos .FunctionMetadataResponse (
343- use_default_metadata_indexing = True ,
344- result = protos .StatusResult (
345- status = protos .StatusResult .Success )))
338+ 'Received WorkerMetadataRequest, request ID %s, function_path: %s' ,
339+ self .request_id , function_path )
346340
347341 try :
342+ validate_script_file_name (script_file_name )
343+
344+ if not os .path .exists (function_path ):
345+ # Fallback to legacy model
346+ logger .info ("%s does not exist. "
347+ "Switching to host indexing." , script_file_name )
348+ return protos .StreamingMessage (
349+ request_id = request .request_id ,
350+ function_metadata_response = protos .FunctionMetadataResponse (
351+ use_default_metadata_indexing = True ,
352+ result = protos .StatusResult (
353+ status = protos .StatusResult .Success )))
354+
348355 fx_metadata_results = self .index_functions (function_path )
349356
350357 return protos .StreamingMessage (
@@ -367,8 +374,6 @@ async def _handle__function_load_request(self, request):
367374 function_id = func_request .function_id
368375 function_metadata = func_request .metadata
369376 function_name = function_metadata .name
370- function_path = os .path .join (function_metadata .directory ,
371- SCRIPT_FILE_NAME )
372377
373378 logger .info (
374379 'Received WorkerLoadRequest, request ID %s, function_id: %s,'
@@ -377,6 +382,14 @@ async def _handle__function_load_request(self, request):
377382 programming_model = "V1"
378383 try :
379384 if not self ._functions .get_function (function_id ):
385+ script_file_name = get_app_setting (
386+ setting = PYTHON_SCRIPT_FILE_NAME ,
387+ default_value = f'{ PYTHON_SCRIPT_FILE_NAME_DEFAULT } ' )
388+ validate_script_file_name (script_file_name )
389+ function_path = os .path .join (
390+ function_metadata .directory ,
391+ script_file_name )
392+
380393 if function_metadata .properties .get ("worker_indexed" , False ) \
381394 or os .path .exists (function_path ):
382395 # This is for the second worker and above where the worker
0 commit comments