[wrangler] GA auto-provision: refactor, expand binding support, add interactivity#13352
[wrangler] GA auto-provision: refactor, expand binding support, add interactivity#13352penalosa wants to merge 10 commits into
Conversation
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR refactors auto-provisioning into per-binding-type handler files, adds 7 new binding types with interactive/CI flows, and introduces a pre-flight check for non-CI-safe bindings.
Issues
-
Dead
configPathcomputation and assertion —configPathis computed on line 158 and asserted on lines 171–174, but is never used afterward (config write-back was removed in this PR). This is dead code that will confuse future readers and causes a spurious assertion failure for programmatic callers that don't set a config file path. -
Unused
autoCreateparameter —provisionBindingsstill accepts anautoCreateparameter (line 154) that is never read. Both callers (deploy.ts:1001andupload.ts:799) passprops.experimentalAutoCreate, but the function body ignores it. The PR description acknowledges this as a known follow-up, but since the parameter actively misleads readers into thinking there's an opt-in gate, it would be cleaner to remove it in this PR. (Can't leave a line-level comment since the signature is outside the diff — just flagging it here.)
| assert( | ||
| configPath, | ||
| "Provisioning resources is not possible without a config file" | ||
| ); |
There was a problem hiding this comment.
configPath is computed (line 158) and asserted here, but it's never used — the config-write-back code that consumed it was removed in this PR. This dead assertion could fail for programmatic callers that don't have a config file path.
| assert( | |
| configPath, | |
| "Provisioning resources is not possible without a config file" | |
| ); |
|
Review posted successfully on PR #13352. I found two actionable issues:
|
f3adcc7 to
22100b3
Compare
Move KV, D1, R2, and AI Search handlers from the monolithic bindings.ts into individual files under provision/. Each handler class now owns its static metadata (bindingType, friendlyName, load, create). Other changes in this refactor: - Search-as-you-type autocomplete replaces the old fixed-list select - Pre-flight check prevents orphaned resources (all-or-nothing in CI) - Random suffix on auto-generated names to prevent collisions - Remove config file write-back (inheritance handles subsequent deploys) - Remove autoCreate/experimentalAutoCreate flag and CLI option - Rewrite provision tests for the new flow
- Add QueueHandler in provision/queue.ts - Make queue_name optional + INHERIT_SYMBOL in Cf types and config - Add INHERIT_SYMBOL handling in upload form - Gate ensureQueuesExistByConfig behind RESOURCES_PROVISION flag - Provision consumer-only queues, de-duplicate by queue_name - Filter undefined producer.queue from trigger display - Add queue provisioning tests
- Add DispatchNamespaceHandler in provision/dispatch-namespace.ts - Export createWorkerNamespace, listWorkerNamespaces, Namespace type - Make namespace optional + INHERIT_SYMBOL in Cf types and config - Add INHERIT_SYMBOL handling in upload form
- Add VectorizeHandler in provision/vectorize.ts - Interactive prompts for dimensions and distance metric - Make index_name optional + INHERIT_SYMBOL in Cf types and config - Add INHERIT_SYMBOL handling in upload form
- Add HyperdriveHandler in provision/hyperdrive.ts - Interactive wizard for connection string, host+port, Access, and VPC origins - Passwords prompted with isSecret: true - Make id optional + INHERIT_SYMBOL in Cf types and config - Add INHERIT_SYMBOL handling in upload form
- Add PipelineHandler in provision/pipeline.ts - Interactive prompt for SQL query - Make pipeline field optional + INHERIT_SYMBOL in Cf types and config - Add INHERIT_SYMBOL handling in upload form
- Add VpcServiceHandler in provision/vpc-service.ts - Interactive wizard for service type, tunnel ID, and origin config - Make service_id optional + INHERIT_SYMBOL in Cf types and config - Add INHERIT_SYMBOL handling in upload form
- Add MtlsCertificateHandler in provision/mtls-certificate.ts - Interactive prompts for cert and key file paths - Make certificate_id optional + INHERIT_SYMBOL in Cf types and config - Add INHERIT_SYMBOL handling in upload form - Fix symbol-to-string coercion in print-bindings
879e241 to
59f83eb
Compare
Phase 1 (correctness regressions): - Revert isFullySpecified = !!nameField on ai-search, queue, dispatch-namespace, vectorize, and pipeline handlers. The pattern was copied incorrectly from opaque-ID handlers (KV, D1, Hyperdrive). For name-based identifiers it short-circuited both the existence check and the creation flow, breaking the core auto-provisioning feature. Name-in-config now correctly flows through isConnectedToExistingResource. - Delete consumer queue provisioning. Consumers are triggers, not bindings, and silently auto-creating typo'd queue names is a footgun. updateQueueConsumers already throws a clean error on missing queues. - Make AI Search namespace field optional in validation/types (handler already supported it; validation was the odd one out). - Fix pre-existing bug in print-bindings where AI Search namespace symbols were stringified before the symbol-detection branch could handle them. - Update affected deploy tests: add listWorkerNamespaces/listPipelines mocks to deploy test scaffolding; gate the legacy 'queue doesn't exist' test behind --x-provision=false to preserve the old pre-provisioning behavior. Phase 2 (high-severity): - search() return type is now Promise<Values | undefined>; prompts autocomplete can return undefined on empty selection and the existing caller already handles it. - Partial provisioning failures now warn with the IDs of resources already created, so the user can reuse or clean them up manually. - Hyperdrive connection-string protocol check uses exact match on postgres:, postgresql:, mysql: rather than startsWith (was too permissive). Phase 3 (medium): - Pipeline: documented the intentional metadata-vs-binding type mismatch (pipelines plural vs pipeline singular). - Vectorize: throw if exactly one of dimensions/metric is set. - VPC Service: removed unchecked as ServiceType cast, uses generic instead. - Hyperdrive: renamed shadowed local config to hdConfig. - Skip search prompt entirely when no existing resources are available. - Replaced bare Error throws with UserError in vectorize/pipeline/vpc/mtls. Phase 4 (low): - Shortened random name suffix from 8 to 4 hex chars. - Reworded pre-flight error message for clarity. - Consolidated repetitive per-handler tests into 5 matrix-driven it.each tests covering 31 test cases across all 11 provisionable binding types: inheritance, fully-specified skip, CI pre-flight blocking, connect-existing, and CI auto-create. Adding a new handler now means adding one entry to bindingCases; the matrix automatically exercises it in all supported scenarios. - Added orphan-warning test for partial provisioning failures.
…ision # Conflicts: # packages/wrangler/src/__tests__/provision.test.ts # packages/wrangler/src/utils/print-bindings.ts
GA the auto-provisioning feature with expanded binding support, interactive UX, and refactored architecture.
Refactoring:
bindings.tsinto one handler file per binding type underprovision/bindingType,friendlyName,load,create)HANDLERSregistry is now a simple map from binding type to handler classNew binding types:
Interactivity:
bucket_name,database_name)Pre-flight check:
Bug fixes:
Removed:
Known follow-ups:
Cf*TypeScript types to match new optional validationautoCreateparameter fromprovisionBindingssignature