Skip to content
Open
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
12 changes: 11 additions & 1 deletion localstack-core/localstack/aws/handlers/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any

from botocore.model import OperationModel, ServiceModel
from plux.core.plugin import PluginDisabled

from localstack import config
from localstack.http import Response
Expand Down Expand Up @@ -222,7 +223,16 @@ def create_exception_response(self, exception: Exception, context: RequestContex
operation = context.service.operation_model(context.service.operation_names[0])
msg = f"exception while calling {service_name} with unknown operation: {message}"

status_code = 501 if config.FAIL_FAST else 500
# Check for license restricted plugin message and set status code to 501
if (
isinstance(exception, PluginDisabled)
and "not part of the active license agreement"
in str(getattr(exception, "reason", "")).lower()
):
status_code = 501
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change the exception message here as well? Current message references the plugin system, which is an internal detail and might not be meaningful to users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error will look something like the following now:
localstack.aws.api.core.CommonServiceException: exception while calling cloudtrail.CreateTrail: This feature is not part of the active license agreement which removes any plugin disabled information.

msg = f"exception while calling {service_name}.{operation.name}: {str(getattr(exception, 'reason', ''))}"
else:
status_code = 501 if config.FAIL_FAST else 500

error = CommonServiceException(
"InternalError", msg, status_code=status_code
Expand Down
Loading