Try to migrate Bitcoin Core wallet to an HD wallet but get "St13runtime" exception I am trying to follow these steps to migrate my wallet to an HD wallet. But it failed, the debug log has errors like this:

EXCEPTION: St13runtime_error
DeriveNewSeed: AddKeyPubKey failed
bitcoin in AppInit()


After some quick search, I found the #issue14422 of bitcoin is related to this issue, which says the upgradewallet option does not work when the wallet is encrypted. The issue is still open and no solution is given. So how can I upgrade my wallet to the HD wallet?
The answer you linked explains how to migrate without using upgradewallet in the section "Versions of Bitcoin Core prior to 0.17`. You will need to follow those steps instead.