Skip to content

wrangler command that offer to add to wrangler.jsonc don't respect existing binding to same resource - should they? #10726

@irvinebroque

Description

@irvinebroque

What versions & operating system are you using?

Wrangler 4.38.0, macos latest

Please provide a link to a minimal reproduction

https://github.com/irvinebroque/workers-for-platforms-example/pull/1/files

Describe the Bug

https://github.com/irvinebroque/workers-for-platforms-example/pull/1/files

Run:

npx wrangler d1 create workers-for-platforms-example-project

This will offer to add to your wrangler.jsonc file. But a binding to that DB already exists (by name but not by ID)

	"d1_databases": [
		{
			"binding": "workers_for_platforms_example_project",
			"database_name": "workers-for-platforms-example-project",
			"database_id": ""
+		},
+		{
+			"binding": "workers_for_platforms_example_project",
+			"database_name": "workers-for-platforms-example-project",
+			"database_id": "c24ad881-6061-4a1b-b83f-d2199ea92a02"
+		}
	],

This is a common pattern because people add the binding name, the binding identifier, and then leave the ID blank — expecting the user to fill this in.

Now, Wrangler can do this, but you then kind of end up with two bindings, both with the same name. And you end up here:

✘ [ERROR] Processing wrangler.jsonc configuration:

    - workers_for_platforms_example_project assigned to multiple D1 Database bindings.
    - Bindings must have unique names, so that they can all be referenced in the worker.
      Please change your bindings to have unique names.

refs cloudflare/workers-for-platforms-example#42

Please provide any relevant error logs

No response

Metadata

Metadata

Assignees

Labels

bugSomething that isn't workingd1Relating to D1

Type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions