Stalin was warned about Hitler’s attack by Richard Sorge and others, but chose to ignore the warnings. Soviet exports of grain and other goods to Germany continued right up until hostilities started. Stalin was so upset by Hitler’s treachery (!) that he supposedly hid under a table in his office for days, barely able to communicate.
This is the scene in the movie “Stalin” that shows he was pretty messed up.....
https://youtu.be/A57gNcOdduo?t=8060
BTW, this is a good movie, I thought, despite the makeup, that Robert Duval did a good job in this movie.