8000 Log exception instead of propagating · localstack/localstack@f12ee63 · GitHub
[go: up one dir, main page]

Skip to content

Commit f12ee63

Browse files
Log exception instead of propagating
1 parent 56276b7 commit f12ee63

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

localstack-core/localstack/aws/handlers/openapi.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
Handlers for validating request and response schema against OpenAPI specs.
33
"""
44

5+
import logging
6+
57
from openapi_core import OpenAPI
68
from openapi_core.contrib.werkzeug import WerkzeugOpenAPIRequest, WerkzeugOpenAPIResponse
9+
from openapi_core.exceptions import OpenAPIError
710

811
from localstack import spec
912
from localstack.aws.api import RequestContext
1013
from localstack.aws.chain import Handler, HandlerChain
1114
from localstack.constants import INTERNAL_RESOURCE_PATH
1215
from localstack.http import Response
1316

17+
LOG = logging.getLogger(__name__)
18+
1419

1520
class OpenAPIRequestValidator(Handler):
1621
def __init__(self):
@@ -20,7 +25,11 @@ def __call__(self, chain: HandlerChain, context: RequestContext, response: Respo
2025
path = context.request.path
2126

2227
if path.startswith(INTERNAL_RESOURCE_PATH) or path.startswith("/_aws/"):
23-
self.openapi.validate_request(WerkzeugOpenAPIRequest(context.request))
28+
try:
29+
self.openapi.validate_request(WerkzeugOpenAPIRequest(context.request))
30+
except OpenAPIError as exc:
31+
# TODO: propagate the exception?
32+
LOG.error(exc)
2433

2534

2635
class OpenAPIResponseValidator(OpenAPIRequestValidator):

0 commit comments

Comments
 (0)
0