workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🐛 BUG: KV & R2 bindings with a empty string ID/name are rejected by the API rather than being caught by config validation

Open KianNH opened this issue 3 years ago • 0 comments

What version of Wrangler are you using?

2.0.24

What operating system are you using?

Mac

Describe the Bug

Bindings with a blank identifier, such as id = "" or bucket_name = "" for kv_namespaces and r2_buckets respectively, throw a workers.api.error.internal_server error as opposed to being caught by config validation in wrangler.

I assume this is since the validation checks for a string, but not if that string has any content.

https://github.com/cloudflare/wrangler2/blob/main/packages/wrangler/src/config/validation.ts#L1633

Example configuration

[[kv_namespaces]]
binding = "foo"
id = ""

[[r2_buckets]]
binding = "bar"
bucket_name = ""

Error returned

Your worker has access to the following bindings:
- KV Namespaces:
  - foo: 
- R2 Buckets:
  - bar: 
Total Upload: 0.29 KiB / gzip: 0.20 KiB

✘ [ERROR] A request to the Cloudflare API (/accounts/134a5a2c0ba47b38eada4b9c8ead10b6/workers/scripts/test-worker) failed.

  workers.api.error.internal_server [code: 10002]

KianNH avatar Aug 11 '22 15:08 KianNH