Catch when doc is null before uploading