Skip to content

Add minimum and maximum version checks for frameworks during auto-configuration#13050

Open
dario-piotrowicz wants to merge 5 commits intomainfrom
dario/DEVX-2525/autoconfig-min-max-versions
Open

Add minimum and maximum version checks for frameworks during auto-configuration#13050
dario-piotrowicz wants to merge 5 commits intomainfrom
dario/DEVX-2525/autoconfig-min-max-versions

Conversation

@dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Mar 24, 2026

Fixes https://jira.cfdata.org/browse/DEVX-2525

When Wrangler automatically configures a project, it now validates the installed version of the detected framework before proceeding:

  • If the version is below the minimum known-good version, the command exits with an error asking the user to upgrade the framework.
  • If the version is above the maximum known major version, a warning is emitted to let the user know the framework version has not been officially tested with this feature, and the command continues.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: UX self-explanatory improvement

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: 98d490a

The changes in this PR will be included in the next version bump.

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

✅ All changesets look good

ask-bonk[bot]

This comment was marked as resolved.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 24, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13050

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13050

miniflare

npm i https://pkg.pr.new/miniflare@13050

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13050

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13050

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13050

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13050

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13050

wrangler

npm i https://pkg.pr.new/wrangler@13050

commit: 98d490a

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Mar 24, 2026

Review posted on PR #13050. The main finding is a logic bug where semiver produces incorrect comparison results when minimumVersion is specified as a bare major number (e.g. "19" instead of "19.0.0"). This causes semiver("19.0.0", "19") to return -1, meaning the minimum version check would incorrectly reject Angular 19.0.0, Astro 4.0.0, Vite 6.0.0, React Router 7.0.0, and any Vike 0.x version as "too old." The fix is straightforward: use full semver strings like "19.0.0" instead of bare majors like "19".

github run

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2525/autoconfig-min-max-versions branch 5 times, most recently from 0511cd7 to 9cdad82 Compare March 25, 2026 13:36
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review March 25, 2026 14:04
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner March 25, 2026 14:04
@workers-devprod
Copy link
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/tests/autoconfig/details/display-auto-config-details.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/autoconfig/frameworks/get-framework-class.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/autoconfig/frameworks/get-framework.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/autoconfig/frameworks/is-framework-supported.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/autoconfig/frameworks/is-known-framework.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/autoconfig/frameworks/validate-framework-version.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/autoconfig/run.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/core.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/details.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/all-frameworks.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/analog.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/angular.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/astro.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/framework-class.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/get-framework.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/hono.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/next.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/nuxt.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/pages.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/qwik.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/react-router.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/solid-start.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/static.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/sveltekit.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/tanstack.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/utils/packages.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/vike.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/vite.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/frameworks/waku.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/run.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/autoconfig/types.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/cli.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2525/autoconfig-min-max-versions branch 2 times, most recently from b74a618 to a69f70b Compare March 25, 2026 14:41
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2525/autoconfig-min-max-versions branch from a69f70b to 84dd3a2 Compare March 25, 2026 14:43
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 8 additional findings in Devin Review.

Open in Devin Review

Comment on lines +75 to +84
if (
semiver(frameworkVersion, frameworkPackageInfo.maximumKnownMajorVersion) >
0
) {
logger.warn(
`The version of ${this.name} used in the project (${JSON.stringify(
frameworkVersion
)}) is not officially known / supported by the Wrangler automatic configuration. So the operation might not complete successfully. Please report this to workers-sdk`
);
}
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 maximumKnownMajorVersion comparison emits spurious warnings for versions with non-zero patch

The semiver(frameworkVersion, frameworkPackageInfo.maximumKnownMajorVersion) comparison at framework-class.ts:76 incorrectly warns for versions within the known major that have a non-zero patch component. When maximumKnownMajorVersion is "4", semiver splits it into ["4"]. The minor comparison (fn(a[1], undefined)) returns 0 due to JS undefined comparison semantics. But the patch comparison uses a || 0 fallback: fn(a[2] || 0, b[2] || 0) where b[2] is """" || 0 = 0. So any non-zero patch triggers a false positive: semiver("4.3.2", "4") returns 1 (warning), while semiver("4.5.0", "4") returns 0 (no warning). In practice, versions like "6.0.3" of Astro (with maximumKnownMajorVersion: "6") would display a misleading warning that the version is "not officially supported". The test at line 113 ("4.3.2" expecting no warning) would also fail for the same reason.

Suggested fix approach

Compare only the major version number instead of using semiver with a partial version string:

const installedMajor = parseInt(frameworkVersion.split(".")[0], 10);
const maxKnownMajor = parseInt(frameworkPackageInfo.maximumKnownMajorVersion, 10);
if (installedMajor > maxKnownMajor) { logger.warn(...); }
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semiver("4.5.0", "4") doesn't return 1 🤔

Screenshot 2026-03-25 at 15 07 43

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a test to ensure that we don't warn: b073efd

@penalosa penalosa requested review from penalosa and removed request for emily-shen March 25, 2026 14:59
projectPath: string
): string | undefined {
try {
// require.resolve on package.json is more reliable so let's try that first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this more reliable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the package.json could not have a resolve export causing require.resolve to throw ERR_PACKAGE_PATH_NOT_EXPORTED this is actually the case for nuxt

however require.resolve on package.json is also not a silver bullet since this only works if the package.json is present in the published package, so I think the best is to try both

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: I'm happy to expand on the code comment if that'd help 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is possible to have a published package that does not contain package.json??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mh... no sorry I think you're right... but there was something regarding the package.json that I saw a while back... like require.resolve not being able to see package.jsons under certain circumstances 🤔 , I'll try to find what that was

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was totally my bad, it seems like require.resolve only detects package.jsons when they are exported: nodejs/node#33460

Screenshot 2026-03-25 at 21 31 31

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

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

4 participants