# Fail to decode argument 0 from table0 to variant { Ok : nat; Err : text }

**URL:** <https://forum.dfinity.org/t/fail-to-decode-argument-0-from-table0-to-variant-ok-nat-err-text/10554>\
**Category:** Developers\
**Created:** [January 28, 2022, 7:09pm UTC](https://forum.dfinity.org/t/fail-to-decode-argument-0-from-table0-to-variant-ok-nat-err-text/10554 "2022-01-28T19:09:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![senior.joinu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/senior.joinu/32/9240_2.png) [@senior.joinu](https://forum.dfinity.org/u/senior.joinu)\
**Post date:** [January 28, 2022, 7:09pm UTC](https://forum.dfinity.org/t/fail-to-decode-argument-0-from-table0-to-variant-ok-nat-err-text/10554/1 "2022-01-28T19:09:59Z")

</div>

I have two canisters, one (in Rust) of which sends a request to another (in Motoko, I don’t have source code for that canister, only types).  
The response has Motoko type `Result.Result<Nat, Text>`, so at the Rust side I’m using the following code:

```auto
    async fn call_test_method(canister_id: Principal) -> CallResult<(Result<Nat, String>,)> {
        call(canister_id, "test_method", ()).await
    }

```

Execution of this function leads to the following error message:

```auto
The Replica returned an error: code 5, message: "Canister knhk5-cyaaa-aaaak-aagoq-cai trapped explicitly: Custom(Fail to decode argument 0 from table0 to variant { Ok : nat; Err : text }

Caused by:
    0: input: 4449444c016b029cc2017de58eb402710100_0124736c6970706167653a20696e73756666696369656e74206f757470757420616d6f756e74
       table: type table0 = variant { 24_860 : nat; 5_048_165 : text }
       wire_type: table0, expect_type: variant { Ok : nat; Err : text }
    1: table0 is not a subtype of variant { Ok : nat; Err : text }
    2: Variant field 24_860 not found in the expected type)"

```

`test_method()` executes successfully, it seems like there is only a decoding issue.  
As I can tell, types `variant { 24_860 : nat; 5_048_165 : text }` and `variant { Ok : nat; Err : text }` are the same, but the error is there for some reason.

What should I do? I’m on `dfx 0.8.4` and `cdk-rs 0.3.3`. The whole thing happens on main-net.

@chenyan

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [January 28, 2022, 7:47pm UTC](https://forum.dfinity.org/t/fail-to-decode-argument-0-from-table0-to-variant-ok-nat-err-text/10554/2 "2022-01-28T19:47:18Z")

</div>

Very likely a mismatch between [rust’s `Result`](https://doc.rust-lang.org/std/result/) which uses `Ok` and `Err`, and [Motoko’s `Result`](https://smartcontracts.org/docs/base-libraries/result), which uses `ok` and `err`.

---

<div class="post-metadata">

**Author:** ![senior.joinu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/senior.joinu/32/9240_2.png) [@senior.joinu](https://forum.dfinity.org/u/senior.joinu)\
**Post date:** [January 28, 2022, 8:06pm UTC](https://forum.dfinity.org/t/fail-to-decode-argument-0-from-table0-to-variant-ok-nat-err-text/10554/3 "2022-01-28T20:06:24Z")

</div>

This should be illegal.  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![diegop](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/diegop/32/569_2.png) [@diegop](https://forum.dfinity.org/u/diegop)\
**Post date:** [January 28, 2022, 9:13pm UTC](https://forum.dfinity.org/t/fail-to-decode-argument-0-from-table0-to-variant-ok-nat-err-text/10554/5 "2022-01-28T21:13:05Z")

</div>

![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/5/515dafb543e078b55c3b88b8fe6c73371d53978c.jpeg)

---

<div class="post-metadata">

**Author:** ![ComputerInternetMan](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/computerinternetman/32/1848_2.png) [@ComputerInternetMan](https://forum.dfinity.org/u/ComputerInternetMan)\
**Post date:** [February 7, 2022, 9:34pm UTC](https://forum.dfinity.org/t/fail-to-decode-argument-0-from-table0-to-variant-ok-nat-err-text/10554/6 "2022-02-07T21:34:26Z")

</div>

Any scheduled sprint for a fix? Not sure this topic should be denoted as ‘solved’.

I went thru the tutorial @senior.joinu (and BTW , brilliant!).

'_and Result type in Motoko is not compatible with the same Result type in Rust. This is why we need … some kind of function to transform Motoko’s Result into Rust’s Result’_
