cloudflare / cloudflare/developer-platform

🐛 BUG: Deploy to Cloudflare button fails with misleading "problem parsing the Wrangler configuration file" when package.json cloudflare metadata has empty preview_image_url

Đang mở
#35 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
awaiting-response:cloudflare
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
1
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

> [!NOTE]
> **Updated after systematic bisection — the original report below the fold blamed `instance_type: "standard-4"`, which turned out to be wrong.** The actual root cause is in `package.json` template metadata, and the error message misattributes it to the Wrangler config file.

### Root cause

The Deploy to Cloudflare button (`POST /api/v4/workers/template-from-worker`, returns 400) fails when `package.json`'s `"cloudflare"` template-metadata block contains an **empty `"preview_image_url": ""`** — and the dashboard reports it as:

> There was a problem parsing the Wrangler configuration file. Please raise an issue in the Workers SDK repo.

The Wrangler config file is not the problem. That misattribution sent us down a long false trail.

### Bisection evidence

All tests run against fresh paths of the same public repo (`tombeckenham/hyperframes-cloudflare-template-tom`), each path a distinct subdirectory so results couldn't be cached (see caching note below):

| Test | Contents | Result |
|---|---|---|
| official `containers-template` verbatim | — | ✅ pass |
| official + this template's full `wrangler.jsonc` (`containers`, Dockerfile image, `standard-4`-equivalent custom instance type, custom build, assets, R2, vars) | config exercised alone | ✅ pass |
| official + this template's `package.json` | metadata exercised alone | ❌ fail |
| same, wrangler devDependency pinned `4.88.0`, no lockfile | rule out wrangler version resolution | ❌ fail |
| same, `"cloudflare"` block deleted | | ✅ pass |
| official + only the `"cloudflare"` block transplanted | converse | ❌ fail |
| block with `"preview_image_url": ""` **removed** (empty `"icon_urls": []` kept) | | ✅ **pass** |
| block with `"icon_urls": []` removed, `"preview_image_url": ""` kept | | ❌ **fail** |
| full app, original `wrangler.jsonc` with `instance_type: "standard-4"`, only `preview_image_url` removed | end-to-end | ✅ **pass** |

So: `"preview_image_url": ""` (empty string) → hard failure with a misleading error. `instance_type: "standard-4"` and the rest of the config are fine. Empty `"icon_urls": []` is fine.

### Reproduction

Any public repo whose `package.json` contains:

```json
"cloudflare": {
"label": "...",
"preview_image_url": ""
}
```

opened via `https://deploy.workers.cloudflare.com/?url=` shows the "problem parsing the Wrangler configuration file" error.

### Suggested fixes

1. Treat an empty/missing `preview_image_url` as "no preview image" instead of failing (it's easy to end up with `""` when scaffolding metadata).
2. If it must be rejected, say so: "Invalid `cloudflare.preview_image_url` in package.json" — not a Wrangler-config parse error pointing at the wrong file.

### Secondary issue: verdict caching makes this near-impossible to debug

The parse verdict appears to be cached per repo/path for at least ~30 minutes, ignoring new commits. Concretely: after a path had passed once, we committed a deliberately **corrupted** `wrangler.jsonc` (unbalanced braces) to that path and the flow still showed the passing configure step; conversely a failing repo kept failing across many fix commits. Anyone iterating on a template fix will conclude their fixes don't work. A cache key including the commit SHA (or a shorter TTL) would fix this.

---

Original (incorrect) report — kept for history

The original report reproduced the same dashboard error on `heygen-com/hyperframes-cloudflare-template` and, based on old wrangler versions locally rejecting `"instance_type": "standard-4"` (`wrangler@4.40.0`: `Expected "containers.instance_type" field to be one of ["dev","basic","standard"]`), concluded the server ran an outdated config schema. That local repro was a coincidence: the server-side failure was the empty `preview_image_url` in `package.json` all along (that repo has both). Environment: macOS 26.5, Node 25.9.0, wrangler 4.85–4.114 all deploy the config fine via CLI.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với khối cloudflare template-metadata trong package.json và tái hiện lỗi thông qua POST /api/v4/workers/template-from-worker hoặc URL Deploy to Cloudflare. Xác minh hành vi khi preview_image_url rỗng hoặc bị thiếu, đồng thời kiểm tra hành vi caching verdict được mô tả trong báo cáo. Được xem là hoàn tất khi metadata không còn gây ra lỗi cấu hình Wrangler gây hiểu nhầm, hoặc response xác định rõ trường package.json không hợp lệ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
json
Lĩnh vực
api, cloud
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.