]> git.proxmox.com Git - proxmox.git/commit
client: fix optional data for errors
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 14 Sep 2023 10:41:30 +0000 (12:41 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 27 Sep 2023 09:27:47 +0000 (11:27 +0200)
commit9fa41851961d0e2eb8b25c495221e82f2bd49c8b
treebdcba94f9583314d0e8544168828669e5c576175
parentdc9ee737512fc2c7325f47b875d6c69ccf484cea
client: fix optional data for errors

previously we changed the internal type of the 'data' property
from Option<T> to T in the assumption the api always returns
'data:null'.

this is actually only the case when the api call succeeds. in an error
case there is no data property at all.

to fix this issue while behaving the same for 'data:null' we have to
revert to Option<T> for RawApiResponse but instead of always throwing an
error for 'data:null' in 'check' we now try there to deserialize from
Value::Null for T if there was no data. This will succeed for the Type
'()' which was the motivation for the original change.

The only downside is that the RawApiResponse now has a trait bound that
T is deserializeable, but was a requirement for using it anyway
(as there was no other way of constructing it)

Fixes: 271a55f ("client: remove option from inner RawApiResponse")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
proxmox-client/src/lib.rs