The issue was that I was deploying using gcloud but not specifying the --function parameter. I had sometimes deployed it using the Console and that is when it was working.
https://cloud.google.com/sdk/gcloud/reference/run/deploy#--function