-
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 PNPM Dependency Parsing Error by Prioritizing Main Dependencies #11291
Conversation
dependency_set << Dependency.new(**dependency_args) | ||
end | ||
|
||
dependencies_without_specifiers.each do |dependency_args| | ||
dependency_set << Dependency.new(**dependency_args) |
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: Instead of processing dependencies without prioritization, we now prioritize main dependencies that include specifiers
in the lock file. This ensures that the main dependency node is preserved, while all other versions (transitive dependencies) are grouped under all_versions
. By doing this, we direct the update process to specifically check if the main dependency is vulnerable, ensuring a more accurate vulnerability assessment.
76e1d81
to
7b8c2d3
Compare
[{ production: !details["dev"] }] | ||
# Add metadata for subdependencies if marked as a dev dependency. | ||
dependency_args[:subdependency_metadata] = [{ production: !details["dev"] }] if details["dev"] | ||
|
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:The above code is just refined.
if Dependabot::Experiments.enabled?(:enable_fix_for_pnpm_no_change_error) | ||
return dependencies_with_prioritization | ||
end | ||
|
||
dependency_set = Dependabot::FileParsers::Base::DependencySet.new |
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: Both methods return dependencies in a similar manner. However, when the feature flag is enabled, the dependencies_with_prioritization
method prioritizes main dependencies over transitive dependencies with the same name but different versions.
What are you trying to accomplish?
This change resolves an issue in PNPM dependency parsing where main dependencies with specifiers were not prioritized, leading to errors or unexpected behavior. By prioritizing main dependencies with
specifiers
in the lock file, the parser ensures that the main dependency node is retained, while transitive dependencies are grouped underall_versions
. This directs the update process to correctly assess the vulnerability status of the main dependency.The behavior is controlled by the feature flag
enable_fix_for_pnpm_no_change_error
, which ensures the changes are incremental and non-disruptive for other use cases.What issues does this affect or fix?
This addresses the "no change" error in PNPM dependency processing, which occurred because main dependencies with specifiers were not prioritized, causing the update process to fail in properly identifying vulnerabilities.
Anything you want to highlight for special attention from reviewers?
The fix adjusts the processing order to prioritize main dependencies with specifiers over others. This approach ensures that:
all_versions
.The use of the
enable_fix_for_pnpm_no_change_error
feature flag ensures that this fix is applied only when the flag is enabled, allowing for safe rollout and evaluation of the changes.How will you know you've accomplished your goal?
Checklist