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

KV Key metadata types too narrow

Open ckohen opened this issue 1 year ago • 3 comments

Between version 3.2.0 and 3.3.0 the type for KV's Key['metadata'] (and MetadataGetResponse) was changed from unknown to Record<string, unknown>.

This type is too narrow, as the metadata can be set to any valid JSON string. Since the value of the metadata is updated as a raw JSON string, this arbitrary nature is very useable. Presumably this is parsed by JSON.parse which respects this behavior. This can either be reverted to unknown, or widened to be a JSONValue type that is essentially most primitives.

ckohen avatar Aug 10 '24 06:08 ckohen

This issue hasn't been updated in a while. If it's still reproducing, please comment to let us know. Thank you!

github-actions[bot] avatar Mar 13 '25 16:03 github-actions[bot]

The associated code has still not been touched and still has this issue

ckohen avatar Mar 14 '25 01:03 ckohen

I've raised an internal ticket with the KV team on this and asked them to weigh in. Thanks!

jhutchings1 avatar Apr 07 '25 21:04 jhutchings1

This issue hasn't been updated in a while. If it's still reproducing, please comment to let us know. Thank you!

github-actions[bot] avatar Jun 07 '25 16:06 github-actions[bot]

This has not been addressed yet

ckohen avatar Jun 15 '25 19:06 ckohen

Don't know why this closed. We are actively working on it with internal ticket KV-1525.

markjmiller avatar Jun 17 '25 22:06 markjmiller

I have no idea why the automation was closing this down. @musa-cf any idea?

jhutchings1 avatar Jun 19 '25 00:06 jhutchings1

This is fixed by https://github.com/cloudflare/cloudflare-typescript/commit/cbdd3e82869bac6065a6b888457c10b7e8541f84#diff-c628bbbc70ea880984554871facce1db33196952aa18d29d3459fbde33088b7d

1000hz avatar Jul 10 '25 20:07 1000hz

Will close with the next PR that merges release / next to main

ckohen avatar Jul 10 '25 21:07 ckohen