For synchronous AWS Lambda invocations, like via API Gateway or direct SDK calls, the value returned by the handler is automatically serialized
into a JSON string before being sent back in the response. If the return value contains objects that are not native JSON types like
datetime
objects, sets, or custom class instances, the serialization will fail, causing a TypeError
. This will prevent the
Lambda from returning a valid response to the client.