more defensive get_cached_payload function
Merge pull request #4975 from dimagi/get-cache

more defensive get_cached_payload function