I have created a MongoDB trigger on a collection with Create, Update, Replace and Delete enabled. Document Preimage is also enabled.
I have connected the trigger to AWS EventBridge. From the EventBridge I’m capturing the events and triggering a Lambda Function with an SQS between the Event bus and the Lambda.
I was testing the the trigger but noticed that the Lambda is not triggering and went on to see the Mongo DB trigger logs from MongoDB Atlas. It showed errors with the following message
Error:
Error sending event to AWS EventBridge: SerializationError: failed to unmarshal response error
status code: 413, request id:
caused by: UnmarshalError: error message missing
I’m not sure what’s causing this. Is it something wrong on MongoDB end or AWS end. I couldn’t find anything related to this by googling.
Due to this error, the trigger may fail to run for the specific change event, and in some cases, it could result in the trigger being suspended, preventing future instances from running on change events.
Cause
The 413 error indicates that the processed change event by the trigger was larger than the allowed limit in AWS. AWS EventBridge triggers have a maximum event size that the AWS ecosystem can accept. The total size of the event for an AWS put entry is set to 256 KB. If the event exceeds this size, the mentioned error will be thrown.
Solution
To reduce the size of the event sent to AWS, specify a Project Expression in the trigger configuration. This limits the number of fields from the document to only the necessary ones.
I believe that requires a support subscription, however I have already updated my first comment to include the details of the kb to answer this particular question.