Skip to content

CLI: Show clear error for non-existent WordPress versions#3065

Open
gcsecsey wants to merge 8 commits intotrunkfrom
gcsecsey/cli-wp-version-error
Open

CLI: Show clear error for non-existent WordPress versions#3065
gcsecsey wants to merge 8 commits intotrunkfrom
gcsecsey/cli-wp-version-error

Conversation

@gcsecsey
Copy link
Copy Markdown
Contributor

@gcsecsey gcsecsey commented Apr 10, 2026

Related issues

Fixes STU-1556

How AI was used in this PR

AI-assisted implementation and testing. All changes reviewed manually.

Proposed Changes

When creating a site with studio site create --wp 8.2, the version passes format validation and the minimum version check, but the version doesn't actually exist. The CLI proceeds through all setup steps (directory creation, SQLite, port assignment) then fails with a generic "Failed to start WordPress server: WordPress server process exited unexpectedly" with no indication the version itself is the problem.

  • Validate the --wp version against the list of available WordPress versions fetched from the WordPress.org API (the same list already used for the interactive version picker)
  • Show a clear error listing available versions when the requested version doesn't exist
  • Support short version formats (e.g. 6.7 matches 6.7.2)
  • Skip validation for latest and nightly, and gracefully degrade if the API is unreachable

Testing Instructions

  • Build the CLI: npm run cli:build
  • Run node apps/cli/dist/cli/main.mjs site create --wp 8.2
  • Verify you see an error like: WordPress version "8.2" is not available. Available versions: nightly, 6.7.2, 6.6.5, ...
  • Run node apps/cli/dist/cli/main.mjs site create --wp 6.7 and verify it works normally
  • Run node apps/cli/dist/cli/main.mjs site create (interactive) and verify it works normally
Before After
CleanShot 2026-04-13 at 12 26 46@2x CleanShot 2026-04-13 at 12 25 03@2x

Using short versions:

Before After
CleanShot 2026-04-14 at 15 06 34@2x CleanShot 2026-04-14 at 15 06 08@2x

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

When a user specifies a non-existent WordPress version via --wp flag,
the command now fails early with a clear error listing available versions
instead of proceeding through all setup steps and failing with a generic
server startup error.
@gcsecsey gcsecsey self-assigned this Apr 10, 2026
Move the version availability check to the top of the handler so it
fails immediately when --wp is passed with a non-existent version,
instead of after the user fills in all interactive prompts.
@gcsecsey gcsecsey requested a review from a team April 13, 2026 11:27
@gcsecsey gcsecsey marked this pull request as ready for review April 13, 2026 11:27
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 13, 2026

📊 Performance Test Results

Comparing 8212553 vs trunk

app-size

Metric trunk 8212553 Diff Change
App Size (Mac) 1286.17 MB 1286.18 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 8212553 Diff Change
load 1927 ms 1677 ms 250 ms 🟢 -13.0%

site-startup

Metric trunk 8212553 Diff Change
siteCreation 9140 ms 9131 ms 9 ms ⚪ 0.0%
siteStartup 4949 ms 4946 ms 3 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@gcsecsey
Copy link
Copy Markdown
Contributor Author

The breaking unit tests seem unrelated to these changes, I pulled in trunk again to rerun them.

try {
const availableVersions = await fetchWordPressVersions();
const isAvailable = availableVersions.some(
( v ) => v.value === wpVersion || v.value.startsWith( wpVersion + '.' )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of just validating that a matching version exists, should we resolve wpVersion to the matched full version? For example, --wp 6.7 actually downloads 6.7.2 instead of 6.7.0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems Playground already handles this and resolves to the latest patch, so feel free to disregard.
The behavior is still somewhat obscure based on Playground behavior, up to you if you feel it makes sense to handle it here or leave as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! I think it's still valuable to add the resolution here, and maybe also add a log message to clarify the resolution if short versions are provided.

Copy link
Copy Markdown
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

I think it is related to picospinner change, but running site create with an unknwon version isn't giving any output. Starting the spinner earlier could solve the issue.

#3035

When --wp flag specifies a non-existent version, show a clear error
listing available versions instead of failing with a generic server
error. Short versions like "6.7" are resolved to full versions like
"6.7.2" with a log message showing the resolution.
picospinner requires the spinner to be running for fail/succeed to
render output. Start it with a "Checking WordPress version" message
before fetching available versions.
Copy link
Copy Markdown
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

Thanks for updating @gcsecsey
Works as described

Image

Trying to use an older patch version fails, but I think that's acceptable/expected

Image

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants