Skip to content
2 changes: 2 additions & 0 deletions localstack-core/localstack/services/events/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can assume that the detail exists here of it would have gone through line 197

Suggested change
elif event.get("Detail") and len(event["Detail"]) >= 262144:
elif 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:
Expand Down
18 changes: 18 additions & 0 deletions tests/aws/services/events/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
16 changes: 15 additions & 1 deletion tests/aws/services/events/test_events.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions tests/aws/services/events/test_events.validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Loading