Skip to content

Commit a5f594a

Browse files
authored
fix: update exception handling in PutLambdaEndpoint API (#18)
1 parent f0a6c08 commit a5f594a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

examples/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def generate_sam_template():
226226
"Timeout": 60,
227227
"MemorySize": 128,
228228
"Environment": {
229-
"Variables": {"DEX_ENDPOINT": {"Ref": "LambdaEndpoint"}}
229+
"Variables": {"AWS_ENDPOINT_URL_LAMBDA": {"Ref": "LambdaEndpoint"}}
230230
},
231231
}
232232
},
@@ -353,7 +353,9 @@ def deploy_function(example_name: str, function_name: str | None = None):
353353
"Description": example_config["description"],
354354
"Timeout": 60,
355355
"MemorySize": 128,
356-
# "Environment": {"Variables": {"AWS_ENDPOINT_URL_LAMBDA": config["lambda_endpoint"]}},
356+
"Environment": {
357+
"Variables": {"AWS_ENDPOINT_URL_LAMBDA": config["lambda_endpoint"]}
358+
},
357359
"DurableConfig": example_config["durableConfig"],
358360
}
359361

src/aws_durable_execution_sdk_python_testing/web/handlers.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,8 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse: #
790790
region_name = body.get("RegionName", "us-east-1")
791791

792792
if not endpoint_url:
793-
return HTTPResponse.create_json(
794-
400, {"error": "EndpointUrl is required"}
793+
return self._handle_aws_exception(
794+
InvalidParameterValueException("EndpointUrl is required")
795795
)
796796

797797
# Update the invoker's Lambda endpoint
@@ -802,7 +802,5 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse: #
802802
{"message": "Lambda endpoint updated successfully"}
803803
)
804804

805-
except (AttributeError, TypeError) as e:
806-
return HTTPResponse.create_json(
807-
500, {"error": f"Failed to update Lambda endpoint: {e!s}"}
808-
)
805+
except Exception as e: # noqa: BLE001
806+
return self._handle_framework_exception(e)

tests/web/handlers_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,8 @@ def test_update_lambda_endpoint_handler_missing_endpoint_url():
21092109
response = handler.handle(update_route, request)
21102110

21112111
assert response.status_code == 400
2112-
assert response.body == {"error": "EndpointUrl is required"}
2112+
assert response.body["Type"] == "InvalidParameterValueException"
2113+
assert response.body["message"] == "EndpointUrl is required"
21132114

21142115

21152116
def test_update_lambda_endpoint_handler_default_region():

0 commit comments

Comments
 (0)