Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions samcli/local/apigw/local_apigw_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from time import time
from typing import Any, Dict, List, Optional, Tuple, Union

from flask import Flask, Request, request
from flask import Flask, Request, jsonify, make_response, request
from werkzeug.datastructures import Headers
from werkzeug.routing import BaseConverter
from werkzeug.serving import WSGIRequestHandler

from samcli.commands.local.lib.exceptions import UnsupportedInlineCodeError
from samcli.commands.local.lib.exceptions import TenantIdValidationError, UnsupportedInlineCodeError
from samcli.commands.local.lib.local_lambda import LocalLambdaRunner
from samcli.lib.providers.exceptions import MissingFunctionNameException
from samcli.lib.providers.provider import Api, Cors
Expand Down Expand Up @@ -739,6 +739,9 @@ def _request_handler(self, **kwargs):

# invoke the route's Lambda function
lambda_response = self._invoke_lambda_function(route.function_name, route_lambda_event, tenant_id)
except TenantIdValidationError as e:
response_data = jsonify({"message": str(e)})
Comment thread Dismissed
endpoint_service_error = make_response(response_data, 400) # HTTP 400 Bad Request
Comment on lines +743 to +744

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to be consistent with the other Errors and add a new method inside the ServiceErrorResponses class instead of calling make_response right here.

But it's just a code refactor that's not critical.

except FunctionNotFound:
endpoint_service_error = ServiceErrorResponses.lambda_not_found_response()
except UnsupportedInlineCodeError:
Expand Down
Loading