Skip to content

Cloudflare Worker: inherit named bindings from an exact prior version #1024

Description

@benpsnyder

Version

alchemy@2.0.0-beta.66

Problem

Cloudflare.Worker can declare binding values through env, but it cannot preserve a named binding from an exact prior Worker version without supplying that binding value again.

That is a problem for least-privilege deployment workflows where:

  • the deployment identity may upload Worker code but cannot read separately custodied secret values;
  • the caller knows the expected binding names and the exact prior version ID;
  • a code-only deploy must preserve those bindings without copying their values through the deployment process; and
  • any missing source version or binding must fail closed rather than silently omit the binding.

Cloudflare already exposes the necessary upload contract:

  • multipart binding metadata supports { type: "inherit", name, version_id };
  • the upload query parameter bindings_inherit=strict fails when an inherited binding cannot be resolved; and
  • Wrangler uses strict inheritance during deploy/version upload.

Alchemy beta.66 has Worker versions and gradual deployments, but I could not find a public Worker prop or binding constructor that emits inherited binding metadata or opts the upload into strict inheritance.

Expected behavior

A Worker deployment should be able to inherit an explicit set of named bindings from an exact prior version without reading their values.

One possible shape:

yield* Cloudflare.Worker("Api", {
  main: "./src/api.ts",
  bindingInheritance: {
    mode: "strict",
    versionId: priorVersionId,
    bindingNames: ["API_TOKEN", "SIGNING_KEY"],
  },
});

A first-class inherited-binding value in env could also work if it stays value-free and supports exact version IDs.

Safety requirements

  • Send bindings_inherit=strict for both regular Worker and dispatch-namespace uploads.
  • Emit type: "inherit" metadata with the exact version_id for every requested name.
  • Include the inheritance contract in the Worker metadata hash/diff surface.
  • Reject an empty version ID, an empty name set, duplicate names, and ambiguous conflicts with explicitly declared bindings.
  • Do not read, log, or persist inherited binding values.
  • Prefer exact version IDs over implicit latest for reproducible plans.

Suggested coverage

  1. An omitted secret binding is inherited from the specified version while its value remains unavailable to Alchemy.
  2. A missing version or binding fails the upload in strict mode.
  3. Changing the version ID or name set produces a Worker update.
  4. Explicitly declared and inherited names cannot conflict silently.
  5. Regular and dispatch-namespace Worker uploads behave consistently.

Cloudflare API references:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions