Skip to content

Fix NpmRunner to handle multi-version npm view output - #15739

Merged
James Newton-King (JamesNK) merged 1 commit into
mainfrom
fix/npm-multiversion-parsing
Apr 1, 2026
Merged

James Newton-King (JamesNK) merged 1 commit into
mainfrom
fix/npm-multiversion-parsing

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

When npm view @playwright/cli@>=0.1.1 version matches multiple published versions, npm returns multi-line output in the format @scope/pkg@version 'version' per line. NpmRunner.ResolvePackageAsync() was calling .Trim() on the entire multi-line string and passing it to SemVersion.TryParse(), which failed.

This broke after versions 0.1.2 and 0.1.3 of @playwright/cli were published on March 31, 2026 — previously only 0.1.1 matched the range, so the output was a single parseable version string.

The fix adds an ExtractLastVersion() method that parses the last (highest) version from multi-line npm output, handling both single-version and multi-version formats.

Fixes #15738

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Copilot AI review requested due to automatic review settings April 1, 2026 00:52
@github-actions

github-actions Bot commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15739

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15739"

Copilot AI left a comment

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.

Pull request overview

Fixes aspire new npm package resolution when npm view <pkg>@<range> version returns multiple matching versions (multi-line output), by extracting a single resolvable version string before passing it to SemVersion.TryParse().

Changes:

  • Update NpmRunner.ResolvePackageAsync() to use a new helper that extracts the last version from npm view output.
  • Add NpmRunner.ExtractLastVersion() to handle both single-line and multi-line npm output formats (including Windows line endings).
  • Add unit tests covering the parsing behavior for single/multiple versions, whitespace/empty output, and prerelease cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Aspire.Cli/Npm/NpmRunner.cs Extracts the last/highest version from multi-line npm view output before SemVer parsing.
tests/Aspire.Cli.Tests/Npm/NpmRunnerTests.cs Adds coverage for the new version-extraction logic across common output variants.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the fix/npm-multiversion-parsing branch from 57bf5c1 to a19a5cd Compare April 1, 2026 00:58
Comment thread src/Aspire.Cli/Npm/NpmRunner.cs Resolved
When a version range like >=0.1.1 matches multiple published versions,
npm view returns multi-line output instead of a single version string.
The existing code tried to parse the entire multi-line output as a
single SemVersion, which failed.

Extract the last (highest) version from the multi-line output format:
  @scope/pkg@version 'version'

Also bumps the @playwright/cli version range from >=0.1.1 to >=0.1.3.

Fixes #15738

Co-authored-by: Copilot <[email protected]>
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the fix/npm-multiversion-parsing branch from a19a5cd to 17374ad Compare April 1, 2026 03:01
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit 17374ad)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23829835738

@JamesNK
James Newton-King (JamesNK) merged commit be10f2f into main Apr 1, 2026
1009 of 1018 checks passed
@JamesNK
James Newton-King (JamesNK) deleted the fix/npm-multiversion-parsing branch April 1, 2026 05:15
@mitchdenny

Copy link
Copy Markdown
Member Author

/backport to release/13.2

@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/13.2 (link to workflow run)

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

No documentation PR is required for this change.

This PR is a bug fix for NpmRunner.ResolvePackageAsync() to handle multi-line output from npm view when multiple package versions match a range. The fix is purely internal (no public API changes, no new user-facing features, no configuration changes), and the author confirmed docs updates are not needed. The existing documentation already covers Playwright integration behavior correctly.

Generated by PR Documentation Check · ● 86.6K · ◷

@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire new fails with "Failed to resolve @playwright/cli@>=0.1.1" when multiple npm versions match the range

4 participants