Skip to content

feat: improve error message when no mature enough matching package is found#9974

Merged
zkochan merged 7 commits intopnpm:mainfrom
btea:feat/add-NO_MATCHING_VERSION_WITH_MINIMUM_RELEASE_AGE
Sep 19, 2025
Merged

feat: improve error message when no mature enough matching package is found#9974
zkochan merged 7 commits intopnpm:mainfrom
btea:feat/add-NO_MATCHING_VERSION_WITH_MINIMUM_RELEASE_AGE

Conversation

@btea
Copy link
Copy Markdown
Member

@btea btea commented Sep 15, 2025

When minimumReleaseAge is configured, if the installation dependencies do not match, the error message below may appear confusing.

image

Comment thread cli/default-reporter/src/reportError.ts Outdated
@zkochan
Copy link
Copy Markdown
Member

zkochan commented Sep 15, 2025

The error message is misleading because it can still be not related to the setting. You can't know without checking the unfiltered original metadata file.

Copy link
Copy Markdown
Member

@zkochan zkochan left a comment

Choose a reason for hiding this comment

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

Maybe we could print in the error when were the versions that satisfy the range published?

Also, test is needed.

Comment thread resolving/npm-resolver/src/index.ts Outdated
@zkochan zkochan requested a review from Copilot September 17, 2025 13:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new error class NoMatchingVersionWithMinimumReleaseAgeError to provide clearer error messaging when package resolution fails due to the minimumReleaseAge configuration. The previous generic "No matching version found" message was confusing when the failure was specifically related to the minimum release age setting.

Key changes:

  • Added a specific error class for minimum release age failures with contextual information
  • Updated error reporting to provide helpful documentation links and explanations
  • Enhanced test coverage to verify the improved error message format

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
resolving/npm-resolver/src/index.ts Adds new error class and logic to throw it when version found but doesn't meet minimum release age
cli/default-reporter/src/reportError.ts Adds error formatting function with helpful documentation link
pkg-manager/plugin-commands-installation/test/add.ts Updates test to expect the new detailed error message format
.changeset/chubby-trees-notice.md Documents the changes for release notes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread resolving/npm-resolver/src/index.ts Outdated
@btea btea requested a review from zkochan September 19, 2025 14:39
@zkochan zkochan requested a review from Copilot September 19, 2025 16:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread resolving/npm-resolver/src/index.ts Outdated
Comment thread cli/default-reporter/src/reportError.ts Outdated
Comment on lines +173 to +181
function stringifyDate (dateStr: string): string {
const now = Date.now()
const oneDayAgo = now - 24 * 60 * 60 * 1000
const date = new Date(dateStr)
if (date.getTime() < oneDayAgo) {
return date.toLocaleDateString()
}
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
}
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The magic number 24 * 60 * 60 * 1000 should be extracted to a named constant like const ONE_DAY_MS = 24 * 60 * 60 * 1000 for better readability and maintainability.

Copilot uses AI. Check for mistakes.
@zkochan zkochan requested a review from Copilot September 19, 2025 16:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

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


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +65 to +66
const time = new Date(opts.packageMeta.time[opts.immatureVersion])
errorMessage = `No matching version found for ${dep} published by ${opts.publishedBy.toString()} while fetching it from ${opts.registry}. Version ${opts.immatureVersion} satisfies the specs but was released at ${time.toString()}`
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The code assumes opts.packageMeta.time[opts.immatureVersion] exists without checking if it's defined. This could cause a runtime error if the time data for the immature version is missing from the package metadata.

Suggested change
const time = new Date(opts.packageMeta.time[opts.immatureVersion])
errorMessage = `No matching version found for ${dep} published by ${opts.publishedBy.toString()} while fetching it from ${opts.registry}. Version ${opts.immatureVersion} satisfies the specs but was released at ${time.toString()}`
const versionTime = opts.packageMeta.time[opts.immatureVersion]
if (versionTime !== undefined) {
const time = new Date(versionTime)
errorMessage = `No matching version found for ${dep} published by ${opts.publishedBy.toString()} while fetching it from ${opts.registry}. Version ${opts.immatureVersion} satisfies the specs but was released at ${time.toString()}`
} else {
errorMessage = `No matching version found for ${dep} published by ${opts.publishedBy.toString()} while fetching it from ${opts.registry}. Version ${opts.immatureVersion} satisfies the specs but its release time is unknown.`
}

Copilot uses AI. Check for mistakes.
Comment on lines +172 to +180
function stringifyDate (dateStr: string): string {
const now = Date.now()
const oneDayAgo = now - 24 * 60 * 60 * 1000
const date = new Date(dateStr)
if (date.getTime() < oneDayAgo) {
return date.toLocaleDateString()
}
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
}
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The function doesn't validate that dateStr is a valid date string. If an invalid date string is passed, new Date(dateStr) will create an Invalid Date object, and calling toLocaleDateString() or toLocaleTimeString() on it could throw an error or return unexpected results.

Copilot uses AI. Check for mistakes.
@zkochan zkochan changed the title feat: add NoMatchingVersionWithMinimumReleaseAgeError feat: improve error message when no mature enough matching package is found Sep 19, 2025
@zkochan zkochan merged commit baf8bf6 into pnpm:main Sep 19, 2025
11 checks passed
@btea btea deleted the feat/add-NO_MATCHING_VERSION_WITH_MINIMUM_RELEASE_AGE branch September 19, 2025 23:47
@Martinspire
Copy link
Copy Markdown

I think it would be helpful to know what version will in fact satisfy the setting?

And I'm not sure but what package version is listed when you do an pnpm outdated and the latest is not available yet due to this setting? How would one know what version to set in that case?

@hlovdal
Copy link
Copy Markdown

hlovdal commented Dec 2, 2025

The current error message is not good enough and still confusing because it fails to explain what is going on. Only people already familiar with minimumReleaseAge (which is not even mentioned in the error message!) will be able to parse it.

The absolutely essential PRIMARY information that should be highlighted and printed in red is something like

Package abc version 1.2.3 rejected due to minimumReleaseAge policy.

The policy value and the age of package abc is essential but secondary information. Everything else is tertiary, non-essential information.

The current error message is something like

Scope: all 16 workspace projects
 WARN  deprecated puppeteer@18.2.1: < 24.15.0 is no longer supported
/download/src/forks/angular-cli/packages/angular/cli:
 ERR_PNPM_NO_MATCHING_VERSION  No matching version found for @modelcontextprotocol/sdk@1.24.1 published by Mon Dec 01 2025 23:22:02 GMT+0100 (Central European Standard Time) while fetching it from https://registry.npmjs.org/. Version 1.24.1 satisfies the specs but was released at Tue Dec 02 2025 19:41:26 GMT+0100 (Central European Standard Time)

This error happened while installing a direct dependency of /download/src/forks/angular-cli/packages/angular/cli

The latest release of @modelcontextprotocol/sdk is "1.24.1". Published at 12/2/2025 19:41:26

Other releases are:
  * beta: 1.23.0-beta.0 published at 11/20/2025

If you need the full list of all 66 published versions run "$ pnpm view @modelcontextprotocol/sdk versions".

If you want to install the matched version ignoring the time it was published, you can add the package name to the minimumReleaseAgeExclude setting. Read more about it: https://pnpm.io/settings#minimumreleaseageexclude
Progress: resolved 99, reused 98, downloaded 0, added 0

and this is not at all clear. The no matching part sounds like the primary problem pnpm had was parsing version information from some source! And then when starting to investigate why pnpm fails to install you start wondering if it is perhaps related to IPv6 or maybe not, etc. After a lot of searching I ended up on this issue which I am relatively sure describes the issue I was having, but I am still only > 90% sure.

Please, please, please fix the error message to convey the essential information like "Package abc version 1.2.3 rejected due to minimumReleaseAge policy".

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.

6 participants