Skip to content

Commit 8c61192

Browse files
authored
Revert "feat: Support all formats of function name in invoke (#8295)" (#8349)
This reverts commit 92e801e.
1 parent 92e801e commit 8c61192

File tree

9 files changed

+7
-304
lines changed

9 files changed

+7
-304
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,9 @@ coverage.xml
414414
tests/integration/buildcmd/scratch
415415
tests/integration/testdata/buildcmd/Dotnet*/bin
416416
tests/integration/testdata/buildcmd/Dotnet*/obj
417-
tests/integration/testdata/buildcmd/Java/**/build/
418417
tests/integration/testdata/invoke/credential_tests/inprocess/dotnet/STS/obj
419418
tests/integration/testdata/sync/code/after/dotnet_function/src/HelloWorld/obj/
420419
tests/integration/testdata/sync/code/before/dotnet_function/src/HelloWorld/obj/
421-
samcli/lib/init/templates/cookiecutter-aws-sam-hello-java-gradle/**/.gradle/
422420

423421
# End of https://www.gitignore.io/api/osx,node,macos,linux,python,windows,pycharm,intellij,sublimetext,visualstudiocode
424422

samcli/commands/local/invoke/cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ def do_cli( # pylint: disable=R0914
190190
from samcli.commands.local.lib.exceptions import NoPrivilegeException, OverridesNotWellDefinedError
191191
from samcli.commands.validate.lib.exceptions import InvalidSamDocumentException
192192
from samcli.lib.providers.exceptions import InvalidLayerReference
193-
from samcli.lib.utils.name_utils import InvalidFunctionNameException
194193
from samcli.local.docker.lambda_debug_settings import DebuggingNotSupported
195194
from samcli.local.docker.manager import DockerImagePullFailedException
196195
from samcli.local.lambdafn.exceptions import FunctionNotFound
@@ -248,7 +247,6 @@ def do_cli( # pylint: disable=R0914
248247
except (
249248
InvalidSamDocumentException,
250249
OverridesNotWellDefinedError,
251-
InvalidFunctionNameException,
252250
InvalidLayerReference,
253251
InvalidIntermediateImageError,
254252
DebuggingNotSupported,

samcli/commands/local/lib/local_lambda.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from samcli.lib.utils.architecture import validate_architecture_runtime
2424
from samcli.lib.utils.codeuri import resolve_code_path
2525
from samcli.lib.utils.colors import Colored
26-
from samcli.lib.utils.name_utils import normalize_lambda_function_name
2726
from samcli.lib.utils.packagetype import IMAGE, ZIP
2827
from samcli.lib.utils.stream_writer import StreamWriter
2928
from samcli.local.docker.container import ContainerConnectionTimeoutException, ContainerResponseException
@@ -128,11 +127,8 @@ def invoke(
128127
When we cannot find a function with the given name
129128
"""
130129

131-
# Normalize function identifier from ARN if provided
132-
normalized_function_identifier = normalize_lambda_function_name(function_identifier)
133-
134130
# Generate the correct configuration based on given inputs
135-
function = self.provider.get(normalized_function_identifier)
131+
function = self.provider.get(function_identifier)
136132

137133
if not function:
138134
all_function_full_paths = [f.full_path for f in self.provider.get_all()]

samcli/lib/utils/name_utils.py

Lines changed: 0 additions & 133 deletions
This file was deleted.

samcli/local/lambda_service/lambda_error_responses.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ class LambdaErrorResponses:
1919
# The request body could not be parsed as JSON.
2020
InvalidRequestContentException = ("InvalidRequestContent", 400)
2121

22-
# One or more parameters values were invalid.
23-
ValidationException = ("ValidationException", 400)
24-
2522
NotImplementedException = ("NotImplemented", 501)
2623

2724
ContainerCreationFailed = ("ContainerCreationFailed", 501)
@@ -88,29 +85,6 @@ def invalid_request_content(message):
8885
exception_tuple[1],
8986
)
9087

91-
@staticmethod
92-
def validation_exception(message):
93-
"""
94-
Creates a Lambda Service ValidationException Response
95-
96-
Parameters
97-
----------
98-
message str
99-
Message to be added to the body of the response
100-
101-
Returns
102-
-------
103-
Flask.Response
104-
A response object representing the ValidationException Error
105-
"""
106-
exception_tuple = LambdaErrorResponses.ValidationException
107-
108-
return BaseLocalService.service_response(
109-
LambdaErrorResponses._construct_error_response_body(LambdaErrorResponses.USER_ERROR, message),
110-
LambdaErrorResponses._construct_headers(exception_tuple[0]),
111-
exception_tuple[1],
112-
)
113-
11488
@staticmethod
11589
def unsupported_media_type(content_type):
11690
"""

samcli/local/lambda_service/local_lambda_invoke_service.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from werkzeug.routing import BaseConverter
99

1010
from samcli.commands.local.lib.exceptions import UnsupportedInlineCodeError
11-
from samcli.lib.utils.name_utils import InvalidFunctionNameException, normalize_lambda_function_name
1211
from samcli.lib.utils.stream_writer import StreamWriter
1312
from samcli.local.docker.exceptions import DockerContainerCreationFailedException
1413
from samcli.local.lambdafn.exceptions import FunctionNotFound
@@ -152,7 +151,7 @@ def _invoke_request_handler(self, function_name):
152151
Parameters
153152
----------
154153
function_name str
155-
Name or ARN of the function to invoke
154+
Name of the function to invoke
156155
157156
Returns
158157
-------
@@ -167,24 +166,15 @@ def _invoke_request_handler(self, function_name):
167166

168167
request_data = request_data.decode("utf-8")
169168

170-
# Normalize function name from ARN if provided
171-
try:
172-
normalized_function_name = normalize_lambda_function_name(function_name)
173-
except InvalidFunctionNameException as e:
174-
LOG.error("Invalid function name: %s", str(e))
175-
return LambdaErrorResponses.validation_exception(str(e))
176-
177169
stdout_stream_string = io.StringIO()
178170
stdout_stream_bytes = io.BytesIO()
179171
stdout_stream_writer = StreamWriter(stdout_stream_string, stdout_stream_bytes, auto_flush=True)
180172

181173
try:
182-
self.lambda_runner.invoke(
183-
normalized_function_name, request_data, stdout=stdout_stream_writer, stderr=self.stderr
184-
)
174+
self.lambda_runner.invoke(function_name, request_data, stdout=stdout_stream_writer, stderr=self.stderr)
185175
except FunctionNotFound:
186-
LOG.debug("%s was not found to invoke.", normalized_function_name)
187-
return LambdaErrorResponses.resource_not_found(normalized_function_name)
176+
LOG.debug("%s was not found to invoke.", function_name)
177+
return LambdaErrorResponses.resource_not_found(function_name)
188178
except UnsupportedInlineCodeError:
189179
return LambdaErrorResponses.not_implemented_locally(
190180
"Inline code is not supported for sam local commands. Please write your code in a separate file."

tests/unit/lib/utils/test_name_utils.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

tests/unit/local/lambda_service/test_lambda_error_responses.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,9 @@ def test_invalid_request_content(self, service_response_mock):
2626
response = LambdaErrorResponses.invalid_request_content("InvalidRequestContent")
2727

2828
self.assertEqual(response, "InvalidRequestContent")
29-
30-
@patch("samcli.local.services.base_local_service.BaseLocalService.service_response")
31-
def test_validation_exception(self, service_response_mock):
32-
service_response_mock.return_value = "ValidationException"
33-
34-
response = LambdaErrorResponses.validation_exception("ValidationException")
35-
36-
self.assertEqual(response, "ValidationException")
37-
3829
service_response_mock.assert_called_once_with(
39-
'{"Type": "User", "Message": "ValidationException"}',
40-
{"x-amzn-errortype": "ValidationException", "Content-Type": "application/json"},
30+
'{"Type": "User", "Message": "InvalidRequestContent"}',
31+
{"x-amzn-errortype": "InvalidRequestContent", "Content-Type": "application/json"},
4132
400,
4233
)
4334

0 commit comments

Comments
 (0)