-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix lambda function name validation for CreateFunction #9825
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Do you think it makes sense to put that logic in a separate function, just to preserve readability in the CreateFunction body?
Possibly. It is rather minor as long as we cannot reuse it. However, if the validation creep continues, we could consider reviving the idea of server-side "boto-spec-based validation abstractions as suggested by Thomas #7675 (comment).": I did a quick try but it didn't work so far (doesn't produce validation errors):
|
@@ -404,6 +404,113 @@ def test_lambda_code_location_s3( | |||
== get_function_response_updated["Configuration"]["CodeSize"] | |||
) | |||
|
|||
# TODO: fix type of AccessDeniedException yielding null | |||
@markers.snapshot.skip_snapshot_verify(paths=["function_arn_other_account_exc..Error.Message"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need some other type of AccessDeniedException
to fix this tiny snapshot diff because AWS returns None
but the exception translates the None message into an empty string:
/Error/Message None (type: <class 'NoneType'>) → '' (type: <class 'str'>)... (expected → actual)
Motivation
The
FunctionName
in the LambdaCreateFunction
operation is currently not validated and cannot handle function ARNs.The AWS API reference describes that the operation can accept the following options for
FunctionName
:This issue came up in a support case where a function ARN crashed in the
event_manager.py
because it tried to create an SQS queue with an invalid name (containing:
).Changes
FunctionName
for the LambdaCreateFunction
operationTesting
tests.aws.services.lambda_.test_lambda_api.TestLambdaFunction.test_function_arns
Notes
CreateFunction
now. However, they often useapi_utils.get_name_and_qualifier
, which supports function ARNs and handles some validations (i.e., qualified and region). If we want to improve server-side validations consistently, we need better boto-spec-based validation abstractions as suggested by @thrau here.FunctionName
cannot be updated, so we don't need to consider renaming.