Fix lambda function name validation for CreateFunction#9825
Conversation
dfangl
left a comment
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
FunctionNamein the LambdaCreateFunctionoperation 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.pybecause it tried to create an SQS queue with an invalid name (containing:).Changes
FunctionNamefor the LambdaCreateFunctionoperationTesting
tests.aws.services.lambda_.test_lambda_api.TestLambdaFunction.test_function_arnsNotes
CreateFunctionnow. 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.FunctionNamecannot be updated, so we don't need to consider renaming.