Hi
Do you use any firewall/vpn/other security software, especially third party. If so, try disabling them.
Try restarting your mac in safe mode and trying, then restart normally.
This sort of error message can also happen with a damaged lirbrary - or one stored on a non compatible volume. Where is your library stored, and if on an external drive, what is the format.
Have you used any duplicate removal software, or any clean up/speed up apps?
How big is your library in iCloud? - how much free space do you have in iCloud? How much free space do you have on your mac?