Conversation
|
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. |
zkochan
left a comment
There was a problem hiding this comment.
Maybe we could print in the error when were the versions that satisfy the range published?
Also, test is needed.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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()}` | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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()}` |
There was a problem hiding this comment.
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.
| 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.` | |
| } |
| 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()}` | ||
| } |
There was a problem hiding this comment.
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.
NoMatchingVersionWithMinimumReleaseAgeError|
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 |
|
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 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 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". |
When
minimumReleaseAgeis configured, if the installation dependencies do not match, the error message below may appear confusing.