cloudflare / cloudflare/cloudflare-prometheus-exporter
bug: wrangler.jsonc ships with empty "id" for CONFIG_KV, causing Wrangler v4 validation failure — container exits immediately on local Docker run
- Dominant language
- TypeScript
- Stars
- 181
- Forks
- 39
- Avg merge
- 11h 28m
- Merged PRs (30d)
- 3
Description
The repository ships a wrangler.jsonc with an empty id field for the CONFIG_KV KV namespace binding. Wrangler v4 added strict validation that rejects empty string IDs at startup, causing the Docker container to exit immediately before serving any requests.
Steps to Reproduce
git clone https://github.com/cloudflare/cloudflare-prometheus-exporter
cd cloudflare-prometheus-exporter
# Note: --frozen-lockfile must be removed due to out-of-sync bun.lock (see below)
docker build -t local-cloudflare-exporter .
docker run --rm -p 8080:8787 \
-e CLOUDFLARE_API_TOKEN="..." \
local-cloudflare-exporter
Actual Result
[ERROR] Processing wrangler.jsonc configuration:
- "kv_namespaces[0]" bindings should have a string "id" field but got
{"binding":"CONFIG_KV","id":""}.
Container exits immediately.
Expected Result
Container starts and serves metrics at http://localhost:8080/metrics.
Root Cause
wrangler.jsonc ships with:
"kv_namespaces": [
{ "binding": "CONFIG_KV", "id": "" }
]
Wrangler v4 validation in packages/workers-utils/src/config/validation.ts explicitly rejects empty-string IDs:
(value.id !== undefined && value.id.length === 0) // triggers error
For local dev (wrangler dev --local), the KV namespace ID is never used — Wrangler simulates KV locally. The id field can either be omitted entirely or set to any non-empty placeholder string.
Proposed Fix
Either of these in wrangler.jsonc:
// Option A — omit id (cleanest, valid for local dev per Wrangler's optional property logic)
{ "binding": "CONFIG_KV" }
// Option B — non-empty placeholder
{ "binding": "CONFIG_KV", "id": "local-placeholder" }
Secondary Issue: bun.lock out of sync
Building the image requires removing --frozen-lockfile from the Dockerfile:
# Current (fails):
RUN bun install --frozen-lockfile
# Workaround:
RUN bun install
The bun.lock file is out of sync with package.json and should be regenerated.
Related Issues
- #19 — env var filtering in Docker entrypoint strips non-CF_/CLOUDFLARE_ prefixed vars
- #20 — no published Docker image on a registry
Environment
- Wrangler: v4.103.0
- Docker: standard local build from repo
- Platform: Linux/macOS
Contributor guide
Research direction
Start with wrangler.jsonc and Dockerfile, then inspect bun.lock and reproduce the documented docker build and run commands. Done means the image builds without the frozen-lockfile failure, the container stays running, and http://localhost:8080/metrics is served without Wrangler validation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, typescript
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100