Skip to content

Response deserialization error - KV Write multiple key-value pairs #248

@GiulianoTS

Description

@GiulianoTS

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions