running rsync over ssh with key-based authentication in Launchd

I wrote a shell script to run on my mac, rsync (over ssh with key-based authentication) over a bunch of content, check that the content that came over is a recent copy, and then do various things based on the new data. When I ran the script on my own it executed perfectly, but when I ran it scheduled through launchd it failed. Even more puzzling was that triggering it to run directly via launchd through LaunchControl would cause it to run correctly.

I was making a really basic mistake. I kept checking the stdout, but I wasn't looking at the stderr. Had I looked at stderr, I would have seen that rsync was throwing errors and it wouldn't have taken me so long to discover the issue: that rsync was failing to sync the files.

It turns out that ssh wasn't automatically loading up my key to authenticate. adding -e 'ssh -i /Users/bob/.ssh/id_rsa' as an argument to rsync to explicitly tell it to invoke ssh with the right identity file was the solution. I'm exceedingly puzzled though, that I reverted the change in the script to try and see what the error that should have tipped me off was exactly, but now the script runs fine even without those options. If you have any thoughts as to why that might be, I'd love to hear them.