Skip to content

fix(migrate): report the location of malformed Wrangler JSONC #697

In review

Description

@coygeek

Summary of the issue

When cf migrate encounters malformed Wrangler JSONC, it exits unsuccessfully and prints the parser code ValueExpected. The diagnostic omits the configuration filename, line and column, so the user has to locate the flagged input separately before correcting it.

Expected behaviour

The migration fails with a diagnostic that identifies the invalid Wrangler configuration and its syntax error location. The existing JSONC parser already computes a source location when it reports a parse error.

Version of cf used

Published npm package cf 1.0.0-rc.1 and the main CI artifact at c240e41bd83591bcf001be1fee094234d154b286.

System information and package versions

macOS 27.2 arm64, Node.js 26.13.1, npm 12.2.2, and @cloudflare/codemods 0.8.1 bundled into the released CLI.

Reproduction (optional)

Run the following from an empty scratch directory using the CLI version listed above. The fixture does not need a Cloudflare account or a Wrangler installation.

printf '%s' '{ "name": ' > wrangler.jsonc
cf migrate --dry-run --bundler vite
printf 'exit=%s\n' "$?"

Relevant error logs (optional)

The published package and the CI build from main produced the same stderr and exited with status 1. Stdout was empty and no migration output file was created.

┌ Error
│ ValueExpected
└

Evidence

  • Expected source: Cloudflare migration guide documents file-based migration previews. The shared JSONC parser constructs a parse error with source position information.
  • Failure source: The exact fixture and stderr above came from local CLI runs. The generic CLI error formatter prints the error message, which is the parser code in the failing runs.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Restoration check

Repeat the malformed fixture. The command should still exit nonzero and leave the input unchanged, and stderr should identify wrangler.jsonc and the error location. A syntactically valid Worker configuration with its dependencies declared should continue to produce a normal migration preview.

Triage assessment

  • Impact level: P3
  • Assessment status: supported
  • Impact basis: The command correctly rejects invalid input. The regression check concerns the diagnostic text used to find the syntax error.
  • Workaround status: available
  • Workaround basis: A JSONC parser used outside the migration command returned wrangler.jsonc:1:11 for the fixture, so a separate syntax check can locate the error.

Activity

  1. zachshallbetter commented on Nov 24, 2026

    @zachshallbetter

    I reproduced this on cf 1.0.0-rc.4 on macOS. With the malformed wrangler.jsonc above, cf migrate --dry-run --bundler vite exits 1 and prints only ValueExpected.

    I have a local patch that reports wrangler.jsonc:1:11: ValueExpected. I checked that the malformed file stays untouched and a valid config still previews successfully. All 20 migration tests and pnpm check passed. Would you be open to a PR for this during the release candidate phase?

  2. workers-devprod commented on Nov 24, 2026

    @workers-devprod
    Collaborator

    @zachshallbetter thanks for confirming this on rc.4. Yes, a pull request for this would be welcome. It will get closed initially but we'll reopen it.

  3. zachshallbetter commented on Nov 25, 2026

    @zachshallbetter

    Thanks for reopening #779. The patch adds file, line, and column to the parse error. I added coverage for malformed TOML, JSON, and JSONC after review, and all 22 migration tests passed locally.

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions