I am using CentOS Stream for one of my VMs and encountered this error. I have not updated my Stream in a while, but this is really annoying thing to deal with. It is not hard to fix, but very inconvient.
The commands below are what worked for me. For some articles online you will have to update the mirrorlist located in /etc/yum.repos.d/
dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos dnf distro-sync
This worked for me.