rust icon indicating copy to clipboard operation
rust copied to clipboard

null is not deserialized correctly

Open notgne2 opened this issue 5 years ago • 3 comments

Using this with Podman will result in invalid type: null, expected a sequence on many endpoints, as empty lists are omitted in favor of null.

I'm not sure if this is an issue in my usage or some change within Serde.

notgne2 avatar Jan 16 '20 05:01 notgne2

Can you point me to the varlink structs which have the problem? Normally "null" means None, and the struct field should be an Option/nullable denoted with a ?.

type MyType (
   example_nullable_array: ?[]string,
   example_nullable_dictionary: ?[string]string,
   example_nullable_stringset: ?[string](),
   example_nullable_array_struct: ?[](first: int, second: string)
)

haraldh avatar Jan 22 '20 08:01 haraldh

The rust varlink generator will produce a #[serde(skip_serializing_if = "Option::is_none")] in this case

haraldh avatar Jan 22 '20 08:01 haraldh

Podman's varlink implementation often gives null in place of an empty array (they use optional arrays too in other places, but those of course work fine). The CLI will reveal this just fine, showing null in place of the array whenever it is empty, but of course other usage will expect a specific type and produce an error.

notgne2 avatar Jan 24 '20 18:01 notgne2