Panicked at Not a valid visitor

I found the solution, but I’m just gonna leave it here for SEO purposes, as I almost lost my sanity trying to figure out what the issue was :zany_face:

While debugging a project with a dev, we faced the following issue in one particular project when calling a canister:

Panicked at 'Not a valid visitor: TypeId { id: 1370, name: "serde_core::de::impls::OptionVisitor<junobuild_collections::types::interface::ListRulesMatcher>" }', /Users/daviddalbusco/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/candid-0.10.17/src/de.rs:602:13
Panicked at 'called `Result::unwrap()` on an `Err` value: Custom(No more values on the wire, the expected type record { matcher : opt record { include_system : bool } } is not opt, null, or reserved)', /Users/daviddalbusco/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/junobuild-satellite-0.2.5/src/lib.rs:168:1

The code was simplified to the maximum and the DID files were up to date, but we still kept facing the issue Not a valid visitor when calling query endpoints.

Hours and a night of sleep later, I finally figured it out: the issue was a dependency mismatch between Serde and Candid.

Cargo.lock pulled in Serde 1.0.225, but was using Candid 0.10.18. However, the problem is that Serde ≥ 1.0.220 requires Candid 0.10.19.

Long story short: updating Candid fixed the issue.

Hope this helps someone in the future!

1 Like