I can’t remove lxd. I’d previously tried to refresh it, but it failed with the same reason.
➜ snap remove lxd --purge
error: cannot perform the following tasks:
- Remove snap "lxd" (21780) from the system (internal error: could not unmarshal state entry "refresh-candidates": json: cannot unmarshal array into Go value of type map[string]*snapstate.refreshCandidate)
I checked git tree of our releases starting from 2.49 and it looks like we only released the final state of this change (in 2.51), so stable releases shouldn’t be affected - unless of course snapd from edge was run at some point and created this entry in the “old” format, in which case stable snapd won’t be able to decode it.
I think this problem should correct itself with first auto-refresh, just make sure you’re not preventing autorefreshes (not holding them). The first successful auto-refresh would store refresh-candidates in the correct format, and then remove will not fail.
Let me know if you did use edge, and if auto-refresh corrected it (snap changes should report an automatic refresh at some point depending on your refresh schedule).
I looked some more into this and I’m very confused and out of ideas for explanation other than what I mentioned earlier… Setting of refresh-candidates has been guarded by experimental.gate-auto-refresh-hook feature flag. Having that feature ON was the only way of getting the “bad” entry into the state (plus, snapd from edge had to be used). The entry would get corrected by auto-refresh with newer snapd as long as that experimental feature is still enabled.
I think I’ll prepare a fix for handling the case where the feature was enabled for a short while on the “bad” version of snapd and then disabled, leaving the bad entry in the state.
UPDATE: later yesterday after looking at the state.json you provided I realized that the value of “refresh-candidates” confirms that at some point in the past you did use snapd from edge channel, since there was an entry for snapd from “latest/edge”. So I think this at least explains half of the mistery.