-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Unsupported Error When Npm Version Not Detected #11430
Conversation
@@ -308,17 +308,19 @@ def detect_version(name) | |||
end | |||
|
|||
# if "packageManager" have no version specified, we check if we can extract "engines" information | |||
detected_version = check_engine_version(name) if !detected_version || detected_version.empty? | |||
detected_version = check_engine_version(name) if detected_version&.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Tip: Simplified
|
||
# if "packageManager" and "engines" both are not present, we check if we can infer the version | ||
# from the manifest file lockfileVersion | ||
detected_version = guessed_version(name) if !detected_version || detected_version.empty? | ||
detected_version = guessed_version(name) if detected_version&.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Tip: Simplified
|
||
detected_version&.to_s | ||
return nil if detected_version.nil? || detected_version.to_s.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Tip: We want to be sure we return nil instead of empty when there is no detected version. Note that detected version can be string or integer.
@@ -327,7 +329,7 @@ def package_manager_by_name(name) | |||
detected_version = detect_version(name) | |||
|
|||
# if we have a detected version, we check if it is deprecated or unsupported | |||
if detected_version | |||
unless detected_version&.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Tip: Check if detected_version has value.
Fix for #11234 |
3eadd3a
to
bc37097
Compare
Can you clarify which version of npm you will default to when none is specified? Whatever npm version ships with with the current node LTS seems reasonable. This sounds like this will fix the issue introduced last week. Also related: #11373 Thanks for getting a fix out for this. |
Let me know if you need any further clarification! |
Great. Works for me thank you. |
The fix has been shipped. Could you check your repository to see if it's working now? You may need to rerun the process to reflect the changes, as the fix was just released. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented review tips
Confirmed working as before. Thank you @kbukum1 |
Thanks for the confirmation. |
What are you trying to accomplish?
This change addresses the issue where the NPM version detection failed when the version is empty or set to 0. The fix ensures that the error is handled gracefully, allowing Dependabot to properly detect and work with NPM versions that were previously unsupported.
Anything you want to highlight for special attention from reviewers?
The fix specifically targets the issue where an unsupported error occurred due to the version being empty or 0. It ensures that these edge cases are handled without causing a disruption in the update process.
How will you know you've accomplished your goal?
Checklist