Bug: Candid encoding not correctly assigning different variants for a `key: variant val` vector
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 204
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
for some reason dfx and didc is not working correctly for encoding a vec with the value which is a variant of different types
For simplicity, I stripped the argument down to only the offending structure, and provide an example with didc (didc 0.1.4) which is enough to replicate the issue
didc decode \
"$(didc encode '(
vec {
record { "name"; variant { TextContent = "blah" } };
record { "ttl"; variant { Nat64Content = 1 : nat64 } };
}
)')"
running this will give you an error:
Error: Trailing value after finishing deserialization
Caused by:
input: 4449444c036d016c02007101026b01ecbfa8c90d71010002046e616d650004626c61680374746c000100_000000000000
table: type table0 = vec table1
type table1 = record { text; table2 }
type table2 = variant { 3_643_416_556 : text }
wire_type: text, expect_type: text
Which it seems to encode everything as that first type it comes across, instead of corresponding variants, as seen by table2
Meta
dfx --version:
dfx 0.11.2
didc --version:
didc 0.1.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided didc encode/decode reproduction with dfx 0.11.2 and didc 0.1.4, focusing on the vec of records containing differently typed variants. Trace the Candid type-table and deserialization path implicated by the error. Done means the example decodes successfully and preserves the TextContent and Nat64Content variant types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100