cloudflare / cloudflare/workers-sdk
🐛 BUG: Workers versions API returns 500 (`invalid placement target type`) for Workers configured with `[placement] region`
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 186
Description
## What happened
Every Worker in our account that sets an explicit placement region fails on the Workers *versions*
API with HTTP 500. The response body is a Go marshalling error:
```
json: error calling MarshalJSON for type *placement.Placement: invalid placement target type:
```
This breaks deploys: `wrangler versions secret bulk` reads `.../versions/latest` first, so our CI
sync-secrets step fails with `[code: 10013]` and the whole deploy pipeline stops. It started
between 16:56 UTC and 21:36 UTC on 2026-09-14. The same pipeline succeeded at 16:56 UTC with no
config change on our side.
## Configuration
`wrangler.toml`, the documented form, one key only:
```toml
[placement]
region = "aws:us-east-2"
```
What the API reports as stored for that Worker
(`GET /accounts/{account}/workers/scripts/{worker}/settings`, HTTP 200):
```json
{ "placement": { "mode": "targeted", "target": [49] } }
```
`target` is an array of an integer. The v2 versions endpoint appears unable to marshal that shape.
## Reproduction
With a token that has Workers read access, against a Worker configured with `[placement] region`:
```bash
# 500 — Go marshalling error in the body
curl -H "Authorization: Bearer $CF_API_TOKEN" \
"https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/workers/workers/$WORKER/versions"
curl -H "Authorization: Bearer $CF_API_TOKEN" \
"https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/workers/workers/$WORKER/versions/latest"
```
Via wrangler (4.129.1 and 4.131.2 behave the same):
```
wrangler versions secret bulk secrets.json --config wrangler.toml --env stg
✘ [ERROR] A request to the Cloudflare API (/accounts/***/workers/workers//versions/latest) failed.
An unknown error has occurred. [code: 10013]
```
## Scope
- 4 of 4 Workers in the account that use `[placement] region` fail, staging and production alike.
- Reproduced repeatedly between 21:36 and 21:53 UTC on 2026-09-14 (7 CI attempts + direct API calls).
- The v1 endpoints are healthy with the same token: `scripts/{worker}/versions`,
`scripts/{worker}/secrets`, `scripts/{worker}/deployments`, `scripts/{worker}/settings` — all 200.
- `wrangler versions list` and `wrangler versions secret list` succeed; only the `versions/latest`
lookup used by the bulk secret write fails.
## Impact
We cannot deploy Workers at all — staging or production — while this is broken. The only local
workaround is dropping region placement, which we cannot do: smart placement put 57% of our
requests in South America while our database is in `aws:us-east-2`, taking per-query latency from
~80 ms to ~320 ms.
## Versions
- wrangler 4.129.1, also verified against 4.131.2
- `[placement] region = "aws:us-east-2"` in `wrangler.toml`, plus an `[env.stg.placement]` block of
the same shape
## Possibly related
- cloudflare/terraform-provider-cloudflare#7273 — the versions API reports `mode: "targeted"`
without a usable target; open since 2026-07-25, flagged for internal review on 2026-08-10.
- cloudflare/workers-sdk#13842 — `wrangler versions secret` not inheriting placement hints; fixed
in 4.88, so the client-side part is already in our version.
Contributor guide
Research direction
Start by reproducing the failure with the documented [placement] region configuration against the versions and versions/latest endpoints, then compare the response with the healthy v1 endpoints. Trace how the stored placement target shape is handled; done means the versions endpoints return successfully and wrangler versions secret bulk can complete without removing region placement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100