This is the error I get:

```
$ bitcoin-cli -rpcwallet=descriptor -testnet upgradewallet                         <
error code: -1
error message:
wallet/rpcwallet.cpp:4522 (operator())
Internal bug detected: '!error.empty()'
You may report this issue here: https://github.com/bitcoin/bitcoin/issues
```

The daemon logs this:

```
2021-07-15T16:16:54Z [descriptor] Performing wallet upgrade to 169900
```

**Expected behavior**

When I do the same on the default (non-descriptor) wallet:

```
$ bitcoin-cli -rpcwallet="" -testnet upgradewallet                             
{
  "wallet_name": "",
  "previous_version": 169900,
  "current_version": 169900,
  "result": "Already at latest version. Wallet version unchanged."
}
```

<!-- **Actual behavior** -->

<!-- See above. Isn't this kind of backwards, to first ask what I expect and then ask what I got? I am writing here because I got something strange in the first place... -->

**System information**

Bitcoin Core v0.21.1 Linux x86_64 glibc (Ubuntu) using binarias from bitcoincore.org

{
private:
    using ScriptPubKeyMap = std::map<CScript, int32_t>; 
    using PubKeyMap = std::map<CPubKey, int32_t>; 
    using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
    using KeyMap = std::map<CKeyID, CKey>;
    ScriptPubKeyMap m_map_script_pub_keys GUARDED_BY(cs_desc_man);
    PubKeyMap m_map_pubkeys GUARDED_BY(cs_desc_man);
    int32_t m_max_cached_index = -1;
    KeyMap m_map_keys GUARDED_BY(cs_desc_man);
    CryptedKeyMap m_map_crypted_keys GUARDED_BY(cs_desc_man);
    
    bool m_decryption_thoroughly_checked = false;
    bool AddDescriptorKeyWithDB(WalletBatch& batch, const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
    KeyMap GetKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
    
    std::unique_ptr<FlatSigningProvider> GetSigningProvider(const CScript& script, bool include_private = false) const;
    
    std::unique_ptr<FlatSigningProvider> GetSigningProvider(const CPubKey& pubkey) const;
    
    std::unique_ptr<FlatSigningProvider> GetSigningProvider(int32_t index, bool include_private = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
protected:
  WalletDescriptor m_wallet_descriptor GUARDED_BY(cs_desc_man);
public:
    DescriptorScriptPubKeyMan(WalletStorage& storage, WalletDescriptor& descriptor)