Skip to content

Reverted route validation #1278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions azure_functions_worker/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ def get_return_binding(binding_name: str,

return return_binding_name

@staticmethod
def validate_binding_route(func_name: str, binding: BindingInfo,
func_type: str):
if hasattr(binding, 'route') and binding.route.startswith(
'/') and func_type == 'function':
raise FunctionLoadError(
func_name,
f'Invalid route name: {binding.route}. Route name cannot begin'
f' with a /')

@staticmethod
def validate_binding_direction(binding_name: str,
binding_direction: str,
Expand All @@ -105,14 +95,6 @@ def validate_binding_direction(binding_name: str,
func_name,
'"$return" binding must have direction set to "out"')

def validate_binding(self, func_name: str, binding: BindingInfo,
func_type: str):
self.validate_binding_route(func_name, binding, func_type)

self.validate_binding_direction(binding.name,
binding.direction,
func_name)

@staticmethod
def is_context_required(params, bound_params: dict,
annotations: dict,
Expand Down Expand Up @@ -377,7 +359,6 @@ def add_function(self, function_id: str,
def add_indexed_function(self, function):
func = function.get_user_function()
func_name = function.get_function_name()
func_type = function.http_type
function_id = str(uuid.uuid5(namespace=uuid.NAMESPACE_OID,
name=func_name))
return_binding_name: typing.Optional[str] = None
Expand All @@ -391,7 +372,9 @@ def add_indexed_function(self, function):

bound_params = {}
for binding in function.get_bindings():
self.validate_binding(func_name, binding, func_type)
self.validate_binding_direction(binding.name,
binding.direction,
func_name)

has_explicit_return, has_implicit_return = \
self.get_explicit_and_implicit_return(
Expand Down
11 changes: 0 additions & 11 deletions tests/unittests/test_functions_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ def dummy():
self.func = Function(self.dummy, "test.py")
self.function_registry = functions.Registry()

def test_add_indexed_function_invalid_route(self):
trigger1 = HttpTrigger(name="req1", route="/")
self.func.add_trigger(trigger=trigger1)

with self.assertRaises(FunctionLoadError) as ex:
self.function_registry.add_indexed_function(function=self.func)

self.assertEqual(str(ex.exception),
'cannot load the dummy function: Invalid route name: '
'/. Route name cannot begin with a /')

def test_add_indexed_function_invalid_direction(self):
trigger1 = HttpTrigger(name="req1", route="test")
binding = BlobInput(name="$return", path="testpath",
Expand Down