Skip to content

Commit ad39c32

Browse files
committed
Revert FileNotFound error
1 parent 9b97a19 commit ad39c32

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

azure_functions_worker/dispatcher.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,11 @@ def load_function_metadata(self, function_app_directory, caller_info):
383383
function_path = os.path.join(function_app_directory,
384384
script_file_name)
385385

386-
if not os.path.exists(function_path):
387-
raise FileNotFoundError("function_app.py not "
388-
f"found in {function_path}")
389-
390-
self._function_metadata_result = self.index_functions(
391-
function_path, function_app_directory)
386+
# For V1, the function path will not exist and
387+
# return None.
388+
self._function_metadata_result = (
389+
self.index_functions(function_path)) \
390+
if os.path.exists(function_path) else None
392391

393392
async def _handle__functions_metadata_request(self, request):
394393
metadata_request = request.functions_metadata_request

tests/unittests/test_dispatcher.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from tests.utils import testutils
2222
from tests.utils.testutils import UNIT_TESTS_ROOT
2323

24-
2524
SysVersionInfo = col.namedtuple("VersionInfo", ["major", "minor", "micro",
2625
"releaselevel", "serial"])
2726
DISPATCHER_FUNCTIONS_DIR = testutils.UNIT_TESTS_FOLDER / 'dispatcher_functions'
@@ -915,34 +914,6 @@ def test_functions_metadata_request_with_indexing_exception(
915914
metadata_response.function_metadata_response.result.status,
916915
protos.StatusResult.Failure)
917916

918-
@patch.dict(os.environ, {PYTHON_ENABLE_INIT_INDEXING: 'false'})
919-
def test_functions_metadata_request_with_filenotfound_exception(self):
920-
921-
request = protos.StreamingMessage(
922-
worker_init_request=protos.WorkerInitRequest(
923-
host_version="2.3.4",
924-
function_app_directory=str(FUNCTION_APP_DIRECTORY)
925-
)
926-
)
927-
928-
metadata_request = protos.StreamingMessage(
929-
functions_metadata_request=protos.FunctionsMetadataRequest(
930-
function_app_directory="NonExistentDirectory"
931-
)
932-
)
933-
934-
self.loop.run_until_complete(
935-
self.dispatcher._handle__worker_init_request(request))
936-
937-
metadata_response = self.loop.run_until_complete(
938-
self.dispatcher._handle__functions_metadata_request(
939-
metadata_request))
940-
941-
self.assertEqual(
942-
metadata_response.function_metadata_response.result.exception.message,
943-
"FileNotFoundError: function_app.py not "
944-
"found in NonExistentDirectory\\function_app.py")
945-
946917
@patch.dict(os.environ, {PYTHON_ENABLE_INIT_INDEXING: 'false'})
947918
def test_dispatcher_indexing_in_load_request(self):
948919
init_request = protos.StreamingMessage(

0 commit comments

Comments
 (0)