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

Deserialization fails when sequence is first parameter at max_depth. #74

Open
kevincox opened this issue Nov 29, 2022 · 0 comments
Open

Comments

@kevincox
Copy link

kevincox commented Nov 29, 2022

I was seeing a confusing error deserailizing a list. It was extra strange because this was working in other places in my code. It seems that there is a weird edge case when parsing a sequence at the max depth value (only tested with Vec and max_depth=1).

	#[derive(serde::Deserialize)]
	pub struct S {
		list: Vec<String>,
		other: bool,
	}

	serde_qs::Config::new(1, false).deserialize_str::<S>("other=true&list%5B%5D=foo").unwrap();
	serde_qs::Config::new(2, false).deserialize_str::<S>("list%5B%5D=foo&other=true").unwrap();
	serde_qs::Config::new(1, false).deserialize_str::<S>("list%5B%5D=foo&other=true").unwrap();

The first two work. My theory is that the first works because the list parameter isn't the first parameter and that the second one works because it has max_depth=2. However the third crashes with the following error:

thread 't' panicked at 'called Result::unwrap() on an Err value: Custom("invalid type: map, expected a sequence")', src/lib.rs:11:87

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

1 participant