diff --git a/localstack-core/localstack/services/events/provider.py b/localstack-core/localstack/services/events/provider.py index 8dc1ca11d47e5..3a9609d40d42d 100644 --- a/localstack-core/localstack/services/events/provider.py +++ b/localstack-core/localstack/services/events/provider.py @@ -197,6 +197,8 @@ def validate_event(event: PutEventsRequestEntry) -> None | PutEventsResultEntry: "ErrorCode": "InvalidArgument", "ErrorMessage": "Parameter Detail is not valid. Reason: Detail is a required argument.", } + elif event.get("Detail") and len(event["Detail"]) >= 262144: + raise ValidationException("Total size of the entries in the request is over the limit.") def check_unique_tags(tags: TagsList) -> None: diff --git a/tests/aws/services/events/test_events.py b/tests/aws/services/events/test_events.py index 35f0aa7696e89..990f972378a6e 100644 --- a/tests/aws/services/events/test_events.py +++ b/tests/aws/services/events/test_events.py @@ -118,6 +118,24 @@ def test_put_event_without_detail(self, snapshot, aws_client): response = aws_client.events.put_events(Entries=entries) snapshot.match("put-events", response) + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_put_event_with_too_big_detail(self, snapshot, aws_client): + entries = [ + { + "Source": TEST_EVENT_PATTERN_NO_DETAIL["source"][0], + "DetailType": TEST_EVENT_PATTERN_NO_DETAIL["detail-type"][0], + "Detail": json.dumps({"payload": ["p" * (256 * 1024 - 17)]}), + }, + ] + + with pytest.raises(ClientError) as e: + aws_client.events.put_events(Entries=entries) + snapshot.match("put-events-too-big-detail-error", e.value.response) + @markers.aws.validated @pytest.mark.skipif( is_old_provider(), diff --git a/tests/aws/services/events/test_events.snapshot.json b/tests/aws/services/events/test_events.snapshot.json index 3df20f8468b1c..4f9eb8a80d190 100644 --- a/tests/aws/services/events/test_events.snapshot.json +++ b/tests/aws/services/events/test_events.snapshot.json @@ -1754,7 +1754,21 @@ ] } }, - "tests/aws/services/events/test_events.py::TestEvents::test_create_connection_validations": { + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_with_too_big_detail": { + "recorded-date": "18-10-2024, 07:36:18", + "recorded-content": { + "put-events-too-big-detail-error": { + "Error": { + "Code": "ValidationException", + "Message": "Total size of the entries in the request is over the limit."}, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_create_connection_validations": { "recorded-date": "14-11-2024, 20:29:49", "recorded-content": { "create_connection_exc": { diff --git a/tests/aws/services/events/test_events.validation.json b/tests/aws/services/events/test_events.validation.json index 7adc430877f4e..eb1027a459232 100644 --- a/tests/aws/services/events/test_events.validation.json +++ b/tests/aws/services/events/test_events.validation.json @@ -164,6 +164,9 @@ "tests/aws/services/events/test_events.py::TestEvents::test_create_connection_validations": { "last_validated_date": "2024-11-14T20:29:49+00:00" }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_with_too_big_detail": { + "last_validated_date": "2024-10-18T07:36:18+00:00" + }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_without_detail": { "last_validated_date": "2024-06-19T10:40:51+00:00" },