Ugh I know the error of which you speak. It’s a quirky one that has to do with baking a texture from an object that has a material using the texture you’re baking. But sometimes it errors and sometimes it doesn’t.
I’m pretty sure the solution is to remove your material, then bake.