Skip to content

[wrangler] Preserve placement on versions secret commands#13843

Merged
petebacondarwin merged 1 commit into
cloudflare:mainfrom
nzws:fix/wrangler-version-secrets-placement-bug
May 15, 2026
Merged

[wrangler] Preserve placement on versions secret commands#13843
petebacondarwin merged 1 commit into
cloudflare:mainfrom
nzws:fix/wrangler-version-secrets-placement-bug

Conversation

@nzws
Copy link
Copy Markdown
Contributor

@nzws nzws commented May 7, 2026

Fixes #13842.

When creating a new version via wrangler versions secret, the previous code only re-emitted a bare { mode: "smart" } placement when the API reported placement_mode === "smart", dropping any other placement entirely. The new version is now created with the placement settings returned by the API, so placement settings survive a secret put/delete/bulk round-trip.

For context, I checked the actual response from /accounts/<account_id>/workers/scripts/<worker_name>/versions/<version_id> and confirmed that the API currently returns the placement settings as expected:

$ curl https://api.cloudflare.com/client/v4/accounts/<account_id>/workers/scripts/<worker_name>/versions/<version_id> \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
  "result": {
    "id": "redacted",
    "number": 11,
    "metadata": {
      "created_on": "2026-05-07T04:52:34.499684Z",
      "source": "dash",
      "author_id": "redacted",
      "author_email": "redacted",
      "has_preview": true
    },
    "annotations": {
      "workers/triggered_by": "version_upload"
    },
    "resources": {
      "script": {
        "etag": "e594a213def980a2febcac3bc35c2b627b7a22ac1264ccd5c6b05533f233e160",
        "handlers": [
          "fetch"
        ],
        "placement_mode": "targeted",
        "placement": {
          "mode": "targeted",
          "target": [
            {
              "id": 12,
              "region": "aws:ap-northeast-1",
              "type": "region"
            }
          ]
        },
        "last_deployed_from": "dash"
      },
      "script_runtime": {
        "compatibility_date": "2026-05-07",
        "compatibility_flags": [
          "nodejs_compat"
        ],
        "usage_model": "standard"
      },
      "bindings": [
        {
          "name": "test",
          "type": "secret_text"
        }
      ]
    }
  },
  "success": true,
  "errors": [],
  "messages": []
}

For reference, here are the response objects observed for each placement setting:

#  Placement: Smart

        "placement_mode": "smart",
        "placement": {
          "mode": "smart"
        },

# Placement: Region

        "placement_mode": "targeted",
        "placement": {
          "mode": "targeted",
          "target": [
            {
              "id": 12,
              "region": "aws:ap-northeast-1",
              "type": "region"
            }
          ]
        },

# Placement: Service

        "placement_mode": "targeted",
        "placement": {
          "mode": "targeted",
          "target": [
            {
              "hostname": "example.com",
              "id": 410,
              "type": "http"
            }
          ]
        },

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This is a bug fix of wrangler.

A picture of a cute animal (not mandatory, but encouraged)

image

@nzws nzws requested a review from workers-devprod as a code owner May 7, 2026 07:06
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

🦋 Changeset detected

Latest commit: f1f9db2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod workers-devprod requested review from a team and petebacondarwin and removed request for a team May 7, 2026 07:07
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented May 7, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk May 11, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13843

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13843

miniflare

npm i https://pkg.pr.new/miniflare@13843

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13843

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13843

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13843

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13843

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13843

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@13843

wrangler

npm i https://pkg.pr.new/wrangler@13843

commit: f1f9db2

@nzws
Copy link
Copy Markdown
Contributor Author

nzws commented May 12, 2026

Hi @penalosa, thanks for the review! The remaining CI failures look unrelated/flaky. Could you re-run them?

@petebacondarwin petebacondarwin force-pushed the fix/wrangler-version-secrets-placement-bug branch from e768365 to f1f9db2 Compare May 14, 2026 15:37
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@petebacondarwin petebacondarwin merged commit 2e72c83 into cloudflare:main May 15, 2026
55 of 58 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

wrangler versions secret commands do not properly inherit the new Placement Hints

5 participants