Skip to content

feat: add Flagship binding support#13139

Merged
petebacondarwin merged 39 commits intocloudflare:mainfrom
roerohan:roerohan/flagship
Apr 10, 2026
Merged

feat: add Flagship binding support#13139
petebacondarwin merged 39 commits intocloudflare:mainfrom
roerohan:roerohan/flagship

Conversation

@roerohan
Copy link
Copy Markdown
Member

@roerohan roerohan commented Mar 31, 2026

Summary

Add end-to-end support for the Flagship binding across @cloudflare/workers-utils, miniflare, and wrangler.

Corresponding workerd PR: cloudflare/workerd#6456

  • @cloudflare/workers-utils: Config schema, validation, default values, CfFlagship type, WorkerMetadataBinding/Binding union entries, and metadata binding mapping
  • miniflare: New remote-only plugin (plugins/flagship/) with zod schema, proxy bindings, and remote proxy client wiring
  • wrangler: Deployment bundle upload, dev wiring (miniflare options, convertConfigToBindings), CLI binding display, type generation (Flags type in both code paths), OAuth scopes (flagship:read, flagship:write), and config-diffs support

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: This PR adds the plumbing only — tests will be added in a follow-up once the workerd Flagship binding types land
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Public docs will be published closer to GA

Open with Devin

Add the Flagship binding to the shared config and type system:
- Add flagship binding type to EnvironmentNonInheritable (environment.ts)
- Add default value flagship: [] (config.ts)
- Add friendly names, notInheritable() validation, and validateFlagshipBinding (validation.ts)
- Add CfFlagship interface and CfWorkerInit.bindings.flagship field (worker.ts)
- Add flagship to WorkerMetadataBinding and Binding union types (types.ts)
- Add flagship case in mapWorkerMetadataBindings (map-worker-metadata-bindings.ts)
Create a new miniflare plugin for Flagship feature flag bindings:
- New plugins/flagship/index.ts with zod schema, getBindings,
  getNodeBindings, and getServices (remote proxy only, no local simulation)
- Register FLAGSHIP_PLUGIN in the PLUGINS object and WorkerOptions type
…elines

Add Flagship binding support across the deployment and dev subsystems:
- Add to getBindings() and createWorkerUploadForm() (deployment-bundle)
- Wire through dev.ts, start-dev.ts, and miniflare/index.ts (dev wiring)
- Add both convert functions in startDevWorker/utils.ts
- Add CLI display in print-bindings.ts (always remote mode)
- Add to ValidKeys exclusion in add-created-resource-config.ts
- Add flagship: [] default in secret/index.ts draft worker
- Add flagship -> Flags type mapping in both type generation code paths
  so `wrangler types` emits FLAGS: Flags for configured flagship bindings
- Add flagship:read and flagship:write to DefaultScopes for wrangler login
@roerohan roerohan requested a review from a team as a code owner March 31, 2026 09:45
@roerohan roerohan requested a review from vicb March 31, 2026 09:45
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

🦋 Changeset detected

Latest commit: 5ce25e1

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

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
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 31, 2026

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/miniflare/src/plugins/flagship/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/index.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/config.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/environment.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/validation.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/map-worker-metadata-bindings.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/types.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/worker.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/core.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/type-generation.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/user.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/whoami.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/utils.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/config-diffs.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev/miniflare/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/type-generation/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/user/user.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/utils/add-created-resource-config.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/utils/print-bindings.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

…vice entry

Match the pattern used by AI and VPC plugins — pass the potentially-undefined
remoteProxyConnectionString through to remoteProxyClientWorker() which handles
the undefined case gracefully, instead of short-circuiting with an empty return.
devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 31, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 5ce25e1

…nding

Warn users who define flagship as an unsafe binding that it is directly
supported by wrangler, matching the pattern of other safe binding types.
devin-ai-integration[bot]

This comment was marked as resolved.

roerohan and others added 4 commits March 31, 2026 15:34
- Rename 'fs' to 'flagshipBinding' in type-generation to avoid shadowing
- Fix formatting in worker.ts and type-generation/index.ts
Add flagship:read and flagship:write to inline snapshot expectations
in user.test.ts (6), deploy/core.test.ts (2), and whoami.test.ts (3).
@petebacondarwin petebacondarwin added the blocked Blocked on other work label Mar 31, 2026
@roerohan
Copy link
Copy Markdown
Member Author

@fixture/vitest-pool-workers:test:ci: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@fixture/vitest-pool-workers:test:ci: 
@fixture/vitest-pool-workers:test:ci:  FAIL   rpc  test/unit.test.ts > Durable Object > increments count and allows direct/rpc access to instance/storage
@fixture/vitest-pool-workers:test:ci: Error: Test timed out in 5000ms.
@fixture/vitest-pool-workers:test:ci: If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
@fixture/vitest-pool-workers:test:ci:  ❯ test/unit.test.ts:72:2
@fixture/vitest-pool-workers:test:ci:      70|   });
@fixture/vitest-pool-workers:test:ci:      71|  });
@fixture/vitest-pool-workers:test:ci:      72|  it("increments count and allows direct/rpc access to instance/storage…
@fixture/vitest-pool-workers:test:ci:        |  ^
@fixture/vitest-pool-workers:test:ci:      73|   expect,
@fixture/vitest-pool-workers:test:ci:      74|  }) => {
@fixture/vitest-pool-workers:test:ci: 
@fixture/vitest-pool-workers:test:ci: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
@fixture/vitest-pool-workers:test:ci: 
@fixture/vitest-pool-workers:test:ci: 
@fixture/vitest-pool-workers:test:ci:  Test Files  1 failed | 49 passed (50)
@fixture/vitest-pool-workers:test:ci:       Tests  1 failed | 131 passed (132)
@fixture/vitest-pool-workers:test:ci:    Start at  12:20:26
@fixture/vitest-pool-workers:test:ci:    Duration  59.98s (transform 13.40s, setup 8.40s, import 21.69s, tests 24.37s, environment 9ms)

This is the current CI error, a simple re-run should fix it
CC @petebacondarwin

@petebacondarwin
Copy link
Copy Markdown
Contributor

But this is not a flake: https://github.com/cloudflare/workers-sdk/actions/runs/23796373130/job/69344578952?pr=13139#step:6:1650

roerohan and others added 4 commits April 1, 2026 11:23
Add flagship binding to bindingsConfigMock to satisfy the
EnvironmentNonInheritable type constraint.
Update 3 inline snapshots that output the full generated Env interface
to include the FLAGS: Flags binding from the flagship config mock.
@github-project-automation github-project-automation bot moved this from Untriaged to In Review in workers-sdk Apr 9, 2026
@roerohan roerohan force-pushed the roerohan/flagship branch from 83b02f1 to 7dd869f Compare April 9, 2026 13:28
@roerohan roerohan requested a review from petebacondarwin April 9, 2026 13:49
Comment thread packages/miniflare/src/index.ts Outdated
Comment thread .changeset/add-flagship-binding.md Outdated
Comment thread pnpm-workspace.yaml
roerohan and others added 2 commits April 9, 2026 19:56
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
@roerohan roerohan force-pushed the roerohan/flagship branch from 9a5fe5f to 195176c Compare April 9, 2026 14:26
Comment thread packages/miniflare/src/plugins/flagship/index.ts Outdated
Comment thread packages/wrangler/src/utils/print-bindings.ts Outdated
roerohan and others added 2 commits April 9, 2026 20:50
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Can you add tests for this binding configuration to packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts.

Can you add tests to miniflare for: getObjectValue, getObjectDetails, getStringDetails, and getNumberDetails.

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 In Review to Approved in workers-sdk Apr 9, 2026
- Add remote field to flagship config, types, and validation
- Fix TS2304: destructure remote in print-bindings flagship map
- Conditionally pass remoteProxyConnectionString based on remote flag
- Remove unused config binding from flagship plugin worker
- Update compatibilityDate to 2025-03-17
devin-ai-integration[bot]

This comment was marked as resolved.

roerohan and others added 3 commits April 10, 2026 01:08
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Strip remote field from flagship bindings in config-diffs.ts
- Add validation tests for flagship binding config
- Add miniflare tests for getObjectValue, getObjectDetails,
  getStringDetails, and getNumberDetails
@petebacondarwin petebacondarwin merged commit 79fd529 into cloudflare:main Apr 10, 2026
58 of 59 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Apr 10, 2026
@roerohan roerohan deleted the roerohan/flagship branch April 10, 2026 08:44
petebacondarwin added a commit that referenced this pull request Apr 13, 2026
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Blocked on other work

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants