Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid IDL Message #506

Closed
infu opened this issue Oct 22, 2021 · 3 comments
Closed

Invalid IDL Message #506

infu opened this issue Oct 22, 2021 · 3 comments

Comments

@infu
Copy link
Contributor

infu commented Oct 22, 2021

throw new Error(`Invalid ${t.display()} argument: ${toReadableString(x)}`);

Is your feature request related to a problem? Please describe.
The error thrown from the above code is not very developer friendly. It's hard to read and figure where the problem is exactly. When you have a record with 10-15 fields, one can waste an hour, trying to figure it out. Not to mention the (Opt) = [ ], which a developer has to figure after searching the documentation and forums.

Describe the solution you'd like
Show exactly which field is causing the problem

Most peculiar things are mentioned in the docs, but I personally missed to see them. https://sdk.dfinity.org/docs/candid-guide/candid-types.html#type-variant

@krpeacock
Copy link
Contributor

@infu do you think this request would be covered under #470?

@infu
Copy link
Contributor Author

infu commented Oct 29, 2021

@krpeacock #470 is about receiving and decoding, while this is about encoding and sending.
This is example error message. Try to figure where the problem is from that error, before checking the solution.

Unhandled Rejection (Error): Invalid record {to:variant {principal:principal; address:text}; metadata:record {ttl:opt nat32; use:opt variant {consumable:record {desc:text; useId:text}; cooldown:record {duration:nat32; desc:text; useId:text}}; thumb:variant {internal:record {contentType:text; size:nat32}; external:record {idx:opt nat32; contentType:text}}; content:opt variant {internal:record {contentType:text; size:nat32}; external:record {idx:opt nat32; contentType:text}}; extensionCanister:opt principal; quality:nat8; hold:opt variant {external:record {desc:text; holdId:text}}; lore:opt text; name:opt text; secret:bool; attributes:vec record {text; int16}; transfer:variant {unrestricted; bindsForever; bindsDuration:nat32}}} argument: {"to":{"address":"504d8fbe45d3dc4ef0cf7f3bcfb0a5a5a80cb0f08e603a02a6f5282fe48e6adb"},"metadata":{"name":["werwer"],"lore":[],"use":[{"cooldown":{"desc":"qweq weqweqweqwe","duration":30,"useId":"qweqweq weqweqwe"}}],"transfer":{"bindsDuration":"1440"},"hold":[],"quality":1,"ttl":[],"attributes":[],"content":[],"thumb":{"internal":{"url":"blob:http://localhost:3000/aa3683bb-1bba-42a2-a7e5-df0dec08abf2","contentType":"image/jpeg","size":8569}},"secret":false,"extensionCanister":[]}}

The error is in bindsDuration, should be nat not string.

@infu
Copy link
Contributor Author

infu commented Oct 14, 2022

fixed #633

@infu infu closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants