From 50049156e5be7d8c63cbd272363ceb7be33458ae Mon Sep 17 00:00:00 2001 From: SHAIK VAHID <38548782+vahidshaik1901@users.noreply.github.com> Date: Sun, 6 Sep 2026 12:37:21 +0530 Subject: [PATCH] fix(wrangler): explain how to resolve a user/deploy configuration conflict When `findRedirectedWranglerConfig()` found a user configuration file and a `.wrangler/deploy/config.json` under different base paths, it reported the conflict and stopped there: Found both a user configuration file at "wrangler.jsonc" and a deploy configuration file at "../.wrangler/deploy/config.json". But these do not share the same base path so it is not clear which should be used. Both paths are discovered by searching up the directory tree independently, so they can settle in different directories, and nothing in the message said which one Wrangler wanted or what to do about it. The reader is left guessing whether to move a file, delete one, or run the command from somewhere else. The message now names the path the deploy configuration would have to sit at to be applied, suggests deleting it when it is left over from a previous build or running the command from the directory that owns the intended configuration, and links to the Generated Wrangler configuration documentation. The expected path was already computed by the conflict check itself, so it is lifted into a variable and reused rather than recomputed. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_018W34ieE3NNGaRQBxj5CKkH --- .changeset/config-conflict-error-guidance.md | 10 ++++++++++ .../workers-utils/src/config/config-helpers.ts | 16 ++++++++++++---- .../tests/config/findWranglerConfig.test.ts | 18 ++++++++++++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 .changeset/config-conflict-error-guidance.md diff --git a/.changeset/config-conflict-error-guidance.md b/.changeset/config-conflict-error-guidance.md new file mode 100644 index 00000000000..6fea3792f1e --- /dev/null +++ b/.changeset/config-conflict-error-guidance.md @@ -0,0 +1,10 @@ +--- +"@cloudflare/workers-utils": patch +"wrangler": patch +--- + +Explain how to resolve a user/deploy configuration conflict + +When a user configuration file and a `.wrangler/deploy/config.json` were found under different base paths, the error stated the conflict but gave no way out of it, leaving the reader to guess whether to move a file, delete one, or run the command somewhere else. + +The message now names the path the deploy configuration would have to sit at to apply, suggests deleting it when it is left over from a previous build or running the command from the directory that owns the intended configuration, and links to the Generated Wrangler configuration documentation. diff --git a/packages/workers-utils/src/config/config-helpers.ts b/packages/workers-utils/src/config/config-helpers.ts index e93f34f43f9..d3d8109ceea 100644 --- a/packages/workers-utils/src/config/config-helpers.ts +++ b/packages/workers-utils/src/config/config-helpers.ts @@ -143,15 +143,23 @@ function findRedirectedWranglerConfig( ); } if (userConfigPath) { - if ( - path.join(path.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== - deployConfigPath - ) { + const expectedDeployConfigPath = path.join( + path.dirname(userConfigPath), + PATH_TO_DEPLOY_CONFIG + ); + if (expectedDeployConfigPath !== deployConfigPath) { throw new UserError( dedent` Found both a user configuration file at "${path.relative(".", userConfigPath)}" and a deploy configuration file at "${path.relative(".", deployConfigPath)}". But these do not share the same base path so it is not clear which should be used. + + A deploy configuration file is generated by a build tool to redirect Wrangler to the configuration it generated. + It is only applied when it sits alongside the user configuration file, which here would be "${path.relative(".", expectedDeployConfigPath)}". + + Please either delete "${path.relative(".", deployConfigPath)}" if it is left over from a previous build, + or run this command from the directory containing the configuration you want to use. + See https://developers.cloudflare.com/workers/wrangler/configuration/#generated-wrangler-configuration `, { telemetryMessage: false } ); diff --git a/packages/workers-utils/tests/config/findWranglerConfig.test.ts b/packages/workers-utils/tests/config/findWranglerConfig.test.ts index 3a9b75fd5c6..e424a4d35de 100644 --- a/packages/workers-utils/tests/config/findWranglerConfig.test.ts +++ b/packages/workers-utils/tests/config/findWranglerConfig.test.ts @@ -239,7 +239,14 @@ describe("config findWranglerConfig()", () => { expect(normalizeString(`${error}`)).toMatchInlineSnapshot(` "Error: Found both a user configuration file at "foo/wrangler.toml" and a deploy configuration file at "foo/bar/.wrangler/deploy/config.json". - But these do not share the same base path so it is not clear which should be used." + But these do not share the same base path so it is not clear which should be used. + + A deploy configuration file is generated by a build tool to redirect Wrangler to the configuration it generated. + It is only applied when it sits alongside the user configuration file, which here would be "foo/.wrangler/deploy/config.json". + + Please either delete "foo/bar/.wrangler/deploy/config.json" if it is left over from a previous build, + or run this command from the directory containing the configuration you want to use. + See https://developers.cloudflare.com/workers/wrangler/configuration/#generated-wrangler-configuration" `); expect(std).toMatchObject(NO_LOGS); @@ -253,7 +260,14 @@ describe("config findWranglerConfig()", () => { expect(normalizeString(`${error}`)).toMatchInlineSnapshot(` "Error: Found both a user configuration file at "bar/foo/wrangler.toml" and a deploy configuration file at "bar/.wrangler/deploy/config.json". - But these do not share the same base path so it is not clear which should be used." + But these do not share the same base path so it is not clear which should be used. + + A deploy configuration file is generated by a build tool to redirect Wrangler to the configuration it generated. + It is only applied when it sits alongside the user configuration file, which here would be "bar/foo/.wrangler/deploy/config.json". + + Please either delete "bar/.wrangler/deploy/config.json" if it is left over from a previous build, + or run this command from the directory containing the configuration you want to use. + See https://developers.cloudflare.com/workers/wrangler/configuration/#generated-wrangler-configuration" `); expect(std).toMatchObject(NO_LOGS); });