Array index out of bounds when upgrade canister

When I try to upgrade my motoko canister, I got an error like this:

dfx canister --network ic install swap --argument="(principal \"$(dfx identity get-principal)\", principal \"$(dfx canister --network ic id swap)\")" -m=upgrade
Upgrading code for canister swap, with canister_id r444h-piaaa-aaaah-qcl3q-cai
The invocation to the wallet call forward method failed with the error: An error happened during the call: 5: Canister r444h-piaaa-aaaah-qcl3q-cai trapped explicitly: Array index out of bounds

Any idea why this happen?