Skip to content

.setBlob() doesn't work in atomic batch when using encryptWith option #20

@lowlighter

Description

@lowlighter

I was trying to use encryptWith in combination of atomic batch for setBlob to store medium-sized objects, and it seems that it doesn't work (in addition of failing silently)

Here you see the transaction getting marked as succesful, but when reading back it's actually empty:

[ { ok: true, versionstamp: "00000000000000060000" } ]
{ key: [ "blob" ], value: null, versionstamp: null }

Minimal reproduction

import { generateKey, openKvToolbox } from "jsr:@kitsonk/kv-toolbox";

const kv = await openKvToolbox({ path: ":memory:", encryptWith: generateKey() });

const res = await kv.atomic()
  .setBlob(["blob"], new TextEncoder().encode("Hello, world!"))
  .commit();
console.log(res);

console.log(await kv.getBlob(["blob"]))

Just removing the encryption key makes the same code works:

[ { ok: true, versionstamp: "00000000000000020000" } ]
{
  key: [ "blob" ],
  value: Uint8Array(13) [
     72, 101, 108, 108, 111,
     44,  32, 119, 111, 114,
    108, 100,  33
  ],
  versionstamp: "00000000000000020000"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions