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

handle leading slashes in KV keys #1559

Merged
merged 3 commits into from
Sep 18, 2020
Merged

Conversation

koeninger
Copy link
Contributor

@koeninger koeninger commented Sep 17, 2020

closes #1560

@koeninger koeninger requested a review from a team as a code owner September 17, 2020 18:42
@ispivey
Copy link
Contributor

ispivey commented Sep 18, 2020

@koeninger is this a breaking change or not? Could you demonstrate that it is or isn't with some tests? cc @xortive

@koeninger
Copy link
Contributor Author

@ispivey shouldn't be a breaking change. I added an additional unit test demonstrating that if someone was working around the bug by encoding, this won't double encode. Here's a manual test as well of this patch vs the latest released wrangler:

leading slashes behavior is fixed:

bash-3.2$ wrangler kv:key get --namespace-id=0ee4a606a6124cd9a36cc0bb7a45b7ea "/leadingslash"
⚠️ Code 10009: get: 'key not found'
�️ Run wrangler kv:key list to see your existing keys

bash-3.2$ cargo run -- kv:key get --namespace-id=0ee4a606a6124cd9a36cc0bb7a45b7ea "/leadingslash"
Finished dev [unoptimized + debuginfo] target(s) in 0.22s
Running target/debug/wrangler 'kv:key' get --namespace-id=0ee4a606a6124cd9a36cc0bb7a45b7ea /leadingslash
someval

non-leading slashes behavior is unchanged:

bash-3.2$ wrangler kv:key get --namespace-id=0ee4a606a6124cd9a36cc0bb7a45b7ea "has/slash"
someval

bash-3.2$ cargo run -- kv:key get --namespace-id=0ee4a606a6124cd9a36cc0bb7a45b7ea "has/slash"
Finished dev [unoptimized + debuginfo] target(s) in 0.60s
Running target/debug/wrangler 'kv:key' get --namespace-id=0ee4a606a6124cd9a36cc0bb7a45b7ea has/slash
someval

Copy link
Contributor

@ispivey ispivey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for demonstrating that it won't unexpectedly change behavior for existing working values 👍

@koeninger koeninger merged commit e32fc6c into cloudflare:master Sep 18, 2020
@koeninger koeninger deleted the kv-slash branch September 18, 2020 19:32
@nataliescottdavidson nataliescottdavidson added this to the 1.12.0 milestone Oct 26, 2020
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 this pull request may close these issues.

Attempt to get key with leading slash returns "not found" error from wrangler
3 participants