Skip to content

wrangler preview: require an explicit previews block only when needed (empty {} should be implied) #150

Open

Description

@buildAI

What versions & operating system are you using?

wrangler 4.158.0, Workers Builds (Node 24)

Describe the Bug

Our assets-only Worker was moved to Workers Previews. Workers Builds now runs npx wrangler preview for every non-production branch. It runs that command even when the Previews Base "Preview command" field is set to something else (wrangler versions upload --preview-alias …).

wrangler preview then fails:

✘ [ERROR] Your Wrangler configuration is missing a `previews` block to run this command.

The docs say the block "can be empty". Adding "previews": {} fixes it, but the block carries no information.

Expected

Either of these:

  • Treat a missing previews block as {}.
  • Or have Workers Builds run the configured Preview command when the Worker has no previews block.

Impact

PR preview builds failed silently for every branch until we added the empty block.

Activity

  1. workers-devprod commented on Nov 6, 2026

    @workers-devprod
    Collaborator

    Automated triage

    Issue assessment

    • Actionability: ✅ Actionable.
    • Type: Bug (medium confidence).
    • Reproduction: Automatic attempt requested.
    • Labels:
      • package:wrangler (high)
      • product:previews (high)
      • bug (medium)
      • feature:workers-builds (medium)
    Actionability and missing information

    wrangler preview (wrangler 4.158.0, Workers Builds) fails with 'Your Wrangler configuration is missing a previews block' for an assets-only Worker whose config omits the block; docs say the block can be empty and adding previews:{} fixes it. Versions, steps, and expected behavior are supplied.

    Reproduction reason: The report describes current wrangler preview behavior with a concrete config scenario and error; running wrangler preview with an assets-only config lacking the previews block can verify it.

    Reproduction

    • Result: ✅ Reproduced.
    • Summary: Reproduced on wrangler 4.158.0: plain wrangler preview (mock Cloudflare API, dummy token) on an assets-only wrangler.json without a previews block fails with the exact reported missing-previews-block error; adding the empty "previews": {} makes the error disappear.
    Evidence and attempted steps

    Steps attempted:

    1. Install the exact wrangler version reported in the issue into the minimal assets-only Worker fixture
      • Command: cd /workspace/reproduction-output/project && pnpm install --ignore-scripts (pins wrangler@4.158.0)
    2. Run the plain wrangler preview command (the command Workers Builds runs) against a local mock Cloudflare API, with wrangler.json lacking a previews block
      • Command: pnpm reproduce (runs wrangler preview with CI=1, CLOUDFLARE_API_BASE_URL=http://127.0.0.1:<mock>, CLOUDFLARE_API_TOKEN=dummy, CLOUDFLARE_ACCOUNT_ID set)
    3. Baseline: temporarily add the reporter's empty-block workaround ("previews": {}), rerun the same command, then restore the config
      • Command: pnpm reproduce:baseline (node reproduce.mjs --with-previews-block)
    4. Context check that the identical error is local config validation firing before any API call
      • Command: wrangler preview --ignore-base-config with dummy token and account id

    Expected behavior: Per the issue, a missing previews block should be treated as {} (the error text itself says the block "can be empty"), so wrangler preview should not fail with a missing-previews-block configuration error.

    Observed behavior: wrangler preview exited 1 with the exact reported error: "[ERROR] Your Wrangler configuration is missing a previews block to run this command. Add the following to your configuration file: { "previews": {} } ... The block can be empty." Baseline with "previews": {} added removed that error entirely; the run then proceeded past config validation and failed on an unrelated sandbox limitation ("Could not determine Preview name. No git branch detected").

    Artifact: ⚠️ Publication failed; the reproduction result was preserved.


    This summary was generated by an LLM and may contain errors. Please verify its findings.

    Triage bot commands and options

    Repository collaborators with write or admin access can trigger actions by commenting on this issue:

    • @workers-devprod reproduce: Attempt to reproduce the issue using its description and recent comments.
  2. moved this from Untriaged to Backlog in workers-sdkon Nov 9, 2026
  3. workers-devprod commented on Nov 13, 2026

    @workers-devprod
    Collaborator

    Thanks for the report. Wrangler deliberately requires a previews block before it creates a Preview, even an empty one, so "previews": {} is the expected setup for a Worker with no bindings. Treating a missing block as {} would be a change to Wrangler, which we track at cloudflare/workers-sdk#16889, so please follow and upvote it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions