Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Attempt to get key with leading slash returns "not found" error from wrangler #1560

Closed
TifMoe opened this issue Sep 17, 2020 · 0 comments Β· Fixed by #1559
Closed

Attempt to get key with leading slash returns "not found" error from wrangler #1560

TifMoe opened this issue Sep 17, 2020 · 0 comments Β· Fixed by #1559

Comments

@TifMoe
Copy link

TifMoe commented Sep 17, 2020

πŸ› Bug Report

Environment

  • operating system: MacOS
  • output of rustc -V: rustc 1.45.1 (c367798cf 2020-07-26)
  • output of node -v: v12.10.0
  • output of wrangler -V: πŸ‘· ✨ wrangler 1.11.0
  • contents of wrangler.toml
type = "webpack"
account_id = "<ACCOUNT-ID>"
zone_id = "<ZONE-ID>"

[env.<STAGING-ENV>]
name = "<STAGING-NAME>"
route = "<STAGING-ROUTE>/*"
kv-namespaces = [{binding = "CACHE", id = "<KV-NAMESPACE-ID>"]

Steps to reproduce

I was trying to get a value from our kv cache using Wrangler but my key has a leading slash:

  1. Validate that I can see the key with a leading slash listed in my namespace
➜  wrangler kv:key list --binding="CACHE" --env=<STAGING-ENV> --prefix="/2050001"
  1. Try to get the key with a leading slash
➜  wrangler kv:key get --binding="CACHE" --env=<STAGING-ENV> "/2050001/1000"       

What did you expect to see?

When I list my keys matching a prefix with a leading slash, I expected to see my key listed

➜  wrangler kv:key list --binding="CACHE" --env=<STAGING-ENV> --prefix="/2050001"
[{"name":"/2050001/1000","expiration":"2020-10-17T18:11:09Z"}]

When I try to get my key with a leading slash, I expected to see my value

➜  wrangler kv:key get --binding="CACHE" --env=<STAGING-ENV> "/2050001/1000" 
<MY-VALUE>    

What did you see instead?

I did see my key listed!

➜  wrangler kv:key list --binding="CACHE" --env=<STAGING-ENV> --prefix="/2050001"
[{"name":"/2050001/1000","expiration":"2020-10-17T18:11:09Z"}]

But when I tried to get it then I encountered a "not found" error

➜  wrangler kv:key get --binding="CACHE" --env=<STAGING-ENV> "/2050001/1000" 
⚠️  Code 10009: get: 'key not found'
πŸ•΅οΈ  Run `wrangler kv:key list` to see your existing keys     
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant