Cannot update Mac OS. "There was an error in Software Update preferences." Mojave I am running Mac OS Mojave 10.14.6 (18G103).

I am getting notifications that mac os has a software update to be installed. However, when I open software updates in system preferences, I get the error "Preferences Error. There was an error in Software Update preferences." My mac will not update. 

The only possible reason that I can think of that this might be happening, is because I tinkered with disabling badge notifications and mac os update notifications using a terminal command. The command I used was 

defaults write com.apple.systempreferences AttentionPrefBundleIDs 0
killall Dock


I'm assuming my error has something to do with a corrupt or misconfigured .plist file but I'm not sure which file I should be looking at and how to check it. Could someone please help me debug this issue? Thank you kindly for your help and patience.
I had a similar error. I my case, I think it was caused by a borked system or Xcode update (not sure which or if something else entirely). 

I was able to get everything back to normal after updating from the Terminal command line using softwareupdate. You can see all the options with

softwareupdate --help


What worked for me was just to install everything that needed to be installed, which I assume included the broken installation, using

sudo softwareupdate --install --all


After a shutdown (not reboot) per the instructions, my computer performed a solid update and all was well.