My KV binding is not being set by my wrangler.toml file when deploying to my production environment

Hello Cloudflare Community!

My KV binding is not being set by my wrangler.toml file when deploying to my production environment.

It works fine on the staging worker, but when I deploy to the production worker the KV binding is wiped, so I have to add it manually using the dashboard after each deploy (which causes downtime).

In my wrangler.toml file, I’m setting kv_namespaces in exactly the same way in [env.production] as I am in [env.staging], and also in the top section of the file (with no environment).

I’ve searched through this community and can’t find any posts on this exact topic.

Below is my full wrangler.toml, and a screenshot of the dashboard with the message recommending updating my wrangler.toml file to keep your local development environment in sync (which I have done).

Thanks very much in advance for your help!

Jeremy

name = "renderer"
account_id = "16875cc7c5ec0ad968518988c731fcab"
workers_dev = false
compatibility_date = "2022-01-20"
main = "src/api/index.ts"

[vars]
ENVIRONMENT = "production"

[build]
command = "npm run build-worker"

kv_namespaces = [
{ binding = "FLOWS_KV", id = "00ca5df4edfa475e82a209d3de5e6d19", preview_id = "00ca5df4edfa475e82a209d3de5e6d19" }
]

[env.production]
vars = { ENVIRONMENT = "production" }
workers_dev = true
kv_namespaces = [
{ binding = "FLOWS_KV", id = "00ca5df4edfa475e82a209d3de5e6d19", preview_id = "00ca5df4edfa475e82a209d3de5e6d19" }
]

[env.staging]
vars = { ENVIRONMENT = "staging" }
kv_namespaces = [
{ binding = "FLOWS_KV", id = "00ca5df4edfa475e82a209d3de5e6d19", preview_id = "00ca5df4edfa475e82a209d3de5e6d19" }
]