Skip to content

Commit f03382d

Browse files
authored
Merge branch 'develop' into dependabot/pip/develop/boto-typing-7e88c84791
2 parents 6f5ed17 + 716ff9a commit f03382d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1979,11 +1979,14 @@ def _call_exception_handler(self, exp: Exception, route: Route) -> Optional[Resp
19791979
exp = service_error
19801980

19811981
if isinstance(exp, RequestValidationError):
1982+
# For security reasons, we hide msg details (don't leak Python, Pydantic or file names)
1983+
errors = [{"loc": e["loc"], "type": e["type"]} for e in exp.errors()]
1984+
19821985
return self._response_builder_class(
19831986
response=Response(
19841987
status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
19851988
content_type=content_types.APPLICATION_JSON,
1986-
body={"statusCode": HTTPStatus.UNPROCESSABLE_ENTITY, "message": exp.errors()},
1989+
body={"statusCode": HTTPStatus.UNPROCESSABLE_ENTITY, "detail": errors},
19871990
),
19881991
serializer=self._serializer,
19891992
route=route,

tests/functional/event_handler/test_bedrock_agent.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ def claims() -> Dict[str, Any]:
121121
assert result["response"]["httpMethod"] == "GET"
122122
assert result["response"]["httpStatusCode"] == 422
123123

124-
body = result["response"]["responseBody"]["application/json"]["body"]
124+
body = json.loads(result["response"]["responseBody"]["application/json"]["body"])
125125
if PYDANTIC_V2:
126-
assert "should be a valid dictionary" in body
126+
assert body["detail"][0]["type"] == "dict_type"
127127
else:
128-
assert "value is not a valid dict" in body
128+
assert body["detail"][0]["type"] == "type_error.dict"
129129

130130

131131
def test_bedrock_agent_event_with_exception():

0 commit comments

Comments
 (0)