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

fix error msg for empty type #478

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/candid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "candid"
version = "0.9.9"
version = "0.9.10"
edition = "2021"
authors = ["DFINITY Team"]
description = "Candid is an interface description language (IDL) for interacting with canisters running on the Internet Computer."
Expand Down
6 changes: 5 additions & 1 deletion rust/candid/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,11 @@ impl<'de> Deserializer<'de> {
where
V: Visitor<'de>,
{
Err(Error::subtype("Cannot decode empty type"))
Err(if *self.wire_type == TypeInner::Empty {
Error::msg("Cannot decode empty type")
} else {
Error::subtype("Cannot decode empty type")
})
}
fn deserialize_future<'a, V>(&'a mut self, visitor: V) -> Result<V::Value>
where
Expand Down
3 changes: 1 addition & 2 deletions rust/candid/src/types/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ impl<'de> Visitor<'de> for IDLValueVisitor {
5u8 => {
use std::io::Read;
let len = leb128::read::unsigned(&mut bytes).map_err(E::custom)? as usize;
let mut buf = Vec::new();
buf.resize(len, 0);
let mut buf = vec![0; len];
bytes.read_exact(&mut buf).map_err(E::custom)?;
let meth = String::from_utf8(buf).map_err(E::custom)?;
let id = crate::Principal::try_from(bytes).map_err(E::custom)?;
Expand Down