Wrangler migration from v1 to v3 and KV namespace issue

I have a small hobby site hosted on Cloudflare.
It is deployed from github as node.js using workers and Wrangler v1.1.0.

As v1 is a legacy version, I want to moved to v3.

I changed version to v3 and updated wrangler.toml from v1 syntax code:

name = "cms" type = "webpack" route = '' zone_id = 'myzone' account_id = 'myaccount' usage_model = '' compatibility_flags = [] workers_dev = true site = {bucket = "./public",entry-point = "workers-site"} compatibility_date = "2022-11-13"

to a recommended syntax from the migration guide:

name = "cms" account_id = 'myaccount' workers_dev = true site = {bucket = "./public",main = "workers-site/index.js"} compatibility_date = "2022-11-13"

Site is deployed without errors, but it is not loading correctly in the browser, there is a KV namespace error:
there is no KV namespace bound to the script

I tried a several versions, with ‘site’ parameter removed, with ‘main’ added, no luck

How can I fix it?

You need to add a KV binding to your wrangler.toml file.

kv_namespaces = [
  { binding = "<KV_NAMESPACE_BINDING>", id = "<KV_NAMESPACE_ID>" }

No change :frowning:

Here is the log:

:rocket: Running Wrangler Commands
/opt/hostedtoolcache/node/18.18.2/x64/bin/npx wrangler deploy
:partly_sunny: wrangler 3.13.2 (update available 3.15.0)
Your worker has access to the following bindings:

  • KV Namespaces:
    • name_I_used: id_I_used
      Total Upload: 53.88 KiB / gzip: 14.17 KiB
      Uploaded cms (1.01 sec)
      No deploy targets for cms (0.42 sec)
      Current Deployment ID: some_id
      :checkered_flag: Wrangler Action completed

in the browser I can see the same message: there is no KV namespace bound to the script

I added account ID and routes to the custom domain and now it shows that all is good (in theory)

Published cms (1.72 sec) https://myname.mydomain.workers.dev www.mydomain.com (custom domain)

still the same there is no KV namespace bound to the script error :thinking:

Do you see there are KV namespaces in the workers settings page?

Yes, I can see it, and it matches the setup. I can see files even.
All look good, even deployments are visible.

The only different is that on v1 it works, on v3 it doesn’t.

Is this in dev or production? Can you share an example of code and wrangler file, so I can try and recreate this issue?

The site setup is almost the same as described here: https://css-tricks.com/how-to-make-a-simple-cms-with-cloudflare-github-actions-and-metalsmith/