Now that we're limiting integers to real-world ranges (eg unsigned integers where it makes sense) more than the spec does, we have a slight mismatch in error codes that fails strict ConformU tests.
At this point we already have too many specializations in
|
self.0 |
|
.swap_remove(name.as_ref()) |
|
.map(|mut value| { |
|
// Specialization: optimized path to avoid cloning the string. |
|
if TypeId::of::<T>() == TypeId::of::<String>() { |
|
return T::deserialize(value.into_deserializer()); |
|
} |
|
// Specialization: booleans in ASCOM must be case-insensitive. |
|
if TypeId::of::<T>() == TypeId::of::<bool>() { |
|
value.make_ascii_lowercase(); |
|
} |
|
serde_plain::from_str(&value) |
|
}) |
and a proper fix would be rewriting that block to use a custom deserializer instead. It should port over the existing behaviour of booleans and strings, while for any integers it should try to parse as
i32 (as per spec) first, map failures to BadRequest, and then do
try_form to the target integer type, and map failures to INVALID_VALUE this time.
Originally reported at ivonnyssen/qhyccd-alpaca#26 (comment) by @ivonnyssen.
Now that we're limiting integers to real-world ranges (eg unsigned integers where it makes sense) more than the spec does, we have a slight mismatch in error codes that fails strict ConformU tests.
At this point we already have too many specializations in
ascom-alpaca-rs/src/server/params.rs
Lines 34 to 46 in 9bc490f
i32(as per spec) first, map failures to BadRequest, and then dotry_formto the target integer type, and map failures to INVALID_VALUE this time.Originally reported at ivonnyssen/qhyccd-alpaca#26 (comment) by @ivonnyssen.