WRONGTYPE Operation against a key holding the wrong kind of value
Manuel Alférez Ruiz

Manuel Alférez Ruiz @manuelalferez

About: Sharing

Location:
España
Joined:
Sep 27, 2020

WRONGTYPE Operation against a key holding the wrong kind of value

Publish Date: Nov 14 '23
0 0

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');
Enter fullscreen mode Exit fullscreen mode

Subsequently, we opt to change the data structure.

await kv.hset('userSession', { userId: 123, email: 'ex@example.com' });
Enter fullscreen mode Exit fullscreen mode

Error:

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

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
Enter fullscreen mode Exit fullscreen mode

Image description

Comments 0 total

    Add comment