SAM local isn't a perfect emulation of the cloud based lambda environment. This is why AWS SAM added the "Accelerate" feature, making it easier to deploy code to the cloud for testing purposes.
https://aws.amazon.com/blogs/compute/accelerating-serverless...