cloudflare-rs icon indicating copy to clipboard operation
cloudflare-rs copied to clipboard

Response deserialization error - KV Write multiple key-value pairs

Open GiulianoTS opened this issue 1 year ago • 1 comments

Recently calls to the endpoint to write multiple key-value pairs to a KV Store started failing with the error message: error decoding response body: invalid type: map, expected unit at line 2 column 12.

I tried to replicate the same call I was doing through the library with Postman, and the response is a success. I dug in the Cloudflare documentation and I think there was an update that broke the deserialization of the response.

See the current version of the docs: https://developers.cloudflare.com/api/operations/workers-kv-namespace-write-multiple-key-value-pairs. And the old one: https://web.archive.org/web/20240527181949/https://developers.cloudflare.com/api/operations/workers-kv-namespace-write-multiple-key-value-pairs.

Steps to reproduce:

    let cloudflare_client: cloudflare::framework::async_api::Client = todo!();
    let pair = cloudflare::endpoints::workerskv::write_bulk::KeyValuePair {
        key: "key".to_string(),
        value: "value".to_string(),
        expiration: None,
        expiration_ttl: None,
        base64: None,
    };
    let request = cloudflare::endpoints::workerskv::write_bulk::WriteBulk {
        account_identifier: "<ACCOUNT_ID>",
        namespace_identifier: "<NAMESPACE_IDENTIFIER>",
        bulk_key_value_pairs: vec![pair],
    };
    cloudflare_client.request(&request).await?;

Cloudflare response body:

{
    "result": {
        "successful_key_count": 1,
        "unsuccessful_keys": []
    },
    "success": true,
    "errors": [],
    "messages": []
}

For additional context: I'm currently on the v0.11.0 version of the library.

GiulianoTS avatar Nov 15 '24 10:11 GiulianoTS