Logo

dev-resources.site

for different kinds of informations.

WRONGTYPE Operation against a key holding the wrong kind of value

Published at
11/14/2023
Categories
kv
vercelkv
vercel
nextjs
Author
Manuel Alfรฉrez Ruiz
Categories
4 categories in total
kv
open
vercelkv
open
vercel
open
nextjs
open
WRONGTYPE Operation against a key holding the wrong kind of value

The error arises when attempting a KV operation (set or get) in Vercel after creating an entry using a different data structure.

Replicating the error

await kv.set('userSession', '123abc');

Subsequently, we opt to change the data structure.

await kv.hset('userSession', { userId: 123, email: '[email protected]' });

Error:

UpstashError: WRONGTYPE Operation against a key holding the wrong kind of value, command was: ["hset","userSession", ...]

Solution

Remove the key from Vercel before modifying the data structure.

  1. Go to Vercel: https://vercel.com/dashboard/stores/kv
  2. Delete that key:
DEL userSession

Image description

Featured ones: