vercel / vercel/storage

data type is changing between `.hset()` and `.hget()`

Open
#727 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
595
Forks
101
Avg merge
2h 24m
Merged PRs (30d)
1

Description

.hget() does not return the type that has been set with .hset()

await kv.hset(`key`, { code1: '123456', code2: '000001' }) // code is a string
const value = await kv.hgetall(`key`)
console.log(typeof value.code1) // code is a number
console.log(typeof value.code2) // code is a string

With automaticDeserialization: false as mentioned here: https://github.com/vercel/storage/issues/250

console.log(typeof value) // value is an 'object'
console.log(typeof value.code) // code is undefined
console.log(typeof JSON.parse(value)) // is not a valid JSON

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the KV hset(), hget(), and hgetall() entry points described in the report, then trace how values are serialized and deserialized, including automaticDeserialization: false. Done means values such as "123456" and "000001" retain their intended types across hset() and hgetall(), with regression coverage for both configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.