Skip to content

Commit

Permalink
validate binding names don't conflict (cloudflare#665)
Browse files Browse the repository at this point in the history
fix: validate that bindings have unique names

We don't want to have, for example, a KV namespace named "DATA"
and a Durable Object also named "DATA". Then it would be ambiguous
what exactly would live at `env.DATA` (or in the case of service workers,
the `DATA` global) which could lead to unexpected behavior -- and errors.

Similarly, we don't want to have multiple resources of the same type
bound to the same name. If you've been working with some KV namespace
called "DATA", and you add a second namespace but don't change the binding
to something else (maybe you're copying-and-pasting and just changed out the `id`),
you could be reading entirely the wrong stuff out of your KV store.

So now we check for those sorts of situations and throw an error if
we find that we've encountered one.
  • Loading branch information
Cass authored Mar 24, 2022
1 parent 8e2cbaf commit 62a89c6
Show file tree
Hide file tree
Showing 5 changed files with 1,133 additions and 372 deletions.
19 changes: 19 additions & 0 deletions .changeset/strange-dingos-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"wrangler": patch
---

fix: validate that bindings have unique names

We don't want to have, for example, a KV namespace named "DATA"
and a Durable Object also named "DATA". Then it would be ambiguous
what exactly would live at `env.DATA` (or in the case of service workers,
the `DATA` global) which could lead to unexpected behavior -- and errors.

Similarly, we don't want to have multiple resources of the same type
bound to the same name. If you've been working with some KV namespace
called "DATA", and you add a second namespace but don't change the binding
to something else (maybe you're copying-and-pasting and just changed out the `id`),
you could be reading entirely the wrong stuff out of your KV store.

So now we check for those sorts of situations and throw an error if
we find that we've encountered one.
Loading

0 comments on commit 62a89c6

Please sign in to comment.