Guide setup of previews block - #15478
Conversation
🦋 Changeset detectedLatest commit: 5057179 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
816057a to
c4cc25c
Compare
There was a problem hiding this comment.
Note
This report is out of date. Scroll down for Devin Review's latest report on this PR.
Devin Review found 4 potential issues.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| }, | ||
| handler: async function previewHandler(args, { config }) { | ||
| const accountId = await requireAuth(config); | ||
| const previewConfig = await ensurePreviewsConfig(accountId, args, config); |
There was a problem hiding this comment.
🟡 Ignore flag imports remote settings
With --ignore-base-config and no local previews block, ensurePreviewsConfig still requires remote settings. The command aborts or copies settings excluded by the flag.
Prompt for agents
Update packages/wrangler/src/preview/preview.ts so ensurePreviewsConfig knows whether --ignore-base-config was supplied. When the flag is true, do not fetch, copy, or require the remote Preview Base configuration. Preserve any intended guidance for locally configured production bindings without contradicting the flag's local-only behavior. Add coverage for a missing local previews block with a non-empty remote base config and --ignore-base-config.
Was this helpful? React with 👍 or 👎 to provide feedback.
| "logpush", | ||
| "observability", | ||
| "limits", | ||
| "placement", |
There was a problem hiding this comment.
🟡 Preview placement bypasses validation
A malformed previews.placement passes validatePreviewsConfig because it is only allowlisted. Preview commands can then crash or send invalid placement.
Prompt for agents
Validate previews.placement in validatePreviewsConfig using the same placement shape and constraints as top-level placement, while reporting the nested previews.placement field path correctly. Add validation tests for non-object values, invalid modes, mutually exclusive targeted fields, and valid smart and targeted configurations.
Was this helpful? React with 👍 or 👎 to provide feedback.
| ...baseConfig | ||
| }: PreviewBaseConfig): PreviewsConfig { | ||
| const bindings = mapWorkerMetadataBindings( | ||
| Object.entries(env ?? {}).map(([name, binding]) => ({ | ||
| name, |
There was a problem hiding this comment.
🟡 Imported bindings lose behavior options
When remote AI or service bindings include staging or cross_account_grant, mapWorkerMetadataBindings drops them. Confirming setup silently changes subsequent preview bindings.
Prompt for agents
Make the Preview Base env-to-config conversion in packages/wrangler/src/preview/preview.ts lossless for all binding properties supported by PreviewsConfig and extractConfigBindings. In particular, preserve AI staging and service cross_account_grant. Either extend mapWorkerMetadataBindings in workers-utils without changing unrelated callers or introduce a preview-specific conversion. Add round-trip tests for these options.
Was this helpful? React with 👍 or 👎 to provide feedback.
| ); | ||
| } | ||
| if (key === "binding" || key === "name" || key === "type") { | ||
| return value; |
There was a problem hiding this comment.
🟡 Generated binding template is invalid
Typed options such as AI staging, queue delays, or rate-limit numbers become strings in replaceProductionConfigValues. The suggested block fails configuration validation.
Prompt for agents
Replace production resource identifiers and user values selectively rather than recursively replacing every primitive. Preserve typed behavioral fields such as booleans and numbers, and preserve non-resource configuration that is safe to reuse. Ensure every generated previews snippet passes normal config validation once required resource placeholders are replaced. Add tests for AI staging, queue options, and rate-limit simple values.
Was this helpful? React with 👍 or 👎 to provide feedback.
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
c4cc25c to
721676c
Compare
1ba678a to
f7f4716
Compare
There was a problem hiding this comment.
Note
This report is out of date. Scroll down for Devin Review's latest report on this PR.
Devin Review found 3 new potential issues.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| const placement = previews?.placement ?? config.placement; | ||
| if (placement) { | ||
| previewDefaults.placement = parseConfigPlacement(placement); |
There was a problem hiding this comment.
f7f4716 to
fd42aed
Compare
fd42aed to
ee8a56c
Compare
de57a51 to
ab95ac1
Compare
…wrangler preview`
ab95ac1 to
5057179
Compare
Fixes WC-5927 and WC-5834.
Primarily improves the onboarding experience for
wrangler preview: guides users along setting up theirpreviewsblock of config.Additionally fixes two bug-ish-things: D1's
database_idvs.idfield, and adds support forplacementin thepreviewsblock of config (already supported by the API). Best reviewed by commit.A picture of a cute animal (not mandatory, but encouraged)