-
Notifications
You must be signed in to change notification settings - Fork 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 rebase creating PR for wrong dependency #10727
Conversation
thanks @sachin-sandhu , please let's get @jakecoffman , @Nishnha , and @landongrindheim to review this as they worked on this area a bit. |
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
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.
I left some comments.
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
So it supersedes the PR. That seems like the behavior Dependabot has always had. Is that a correct summary of the issue? If the dependencies are updating too frequently the solution would be to have Dependabot run less frequent than daily, maybe weekly. Edit: Ah ok this repo makes the problem pretty clear: https://github.com/brettfo/dependabot-npm-closing |
It appears this PR will break rebases. We do need Dependabot to rebase jobs even if an existing PR exists with the same version, that's a feature of rebasing. For example: Dependabot posts the PR, and new commits go to the main branch. Users will want to It seems the bug here is that a rebase job is producing different results from the job that created it, probably because of the grouped nature of the update. So we need to track down why that is happening instead of preventing the rebase. |
updater/lib/dependabot/updater/operations/refresh_security_update_pull_request.rb
Outdated
Show resolved
Hide resolved
@@ -1172,6 +1172,122 @@ def expect_update_checker_with_ignored_versions(versions, dependency_matcher: an | |||
end | |||
end | |||
|
|||
context "when the security advisory job is used as lead dependency" do |
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.
The top of this file has a comment:
DO NOT ADD NEW TESTS TO THIS FILE
This would be a perfect candidate for a "silent test" for multidir-rebase. Here's a multidir-create test you can modify to add a rebase: https://github.com/dependabot/dependabot-core/blob/e63dc2cf45f6d2d6ca29ed49433a26eb74c5fcfc/silent/tests/testdata/su-multidir.txt
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.
I have moved tests cases to relevant file and also added silent tests for security rebases
@@ -113,6 +113,7 @@ | |||
|
|||
before do | |||
allow(Dependabot::Experiments).to receive(:enabled?).with(:bundler_v1_unsupported_error).and_return(false) | |||
allow(Dependabot::Experiments).to receive(:enabled?).with(:lead_security_dependency).and_return(false) |
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.
I would suggest turning the experiment on in these tests as we believe this is the right way to do security updates with a single dependency going forward.
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.
added a new test for single dependency update, this particular test case is intended towards deprecation notices
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.
Nice work!
6d5e3ce
to
9baebdd
Compare
What are you trying to accomplish?
Preface: This issue is related with closing and creating new pull requests.
Issue: Azure Dev Ops team (likely not limited to) is facing an issue where is closing and recreating an existing PR which is resulting in multiple PRs being generated every day. i.e.
Here the existing pull request already exists for lead dependency
express
. This can be seen from job snapshot as following:On dependabot scanning existing PR, it does not takes the existing PR snapshot into account. i.e. the rerun pr log is as following:
Issues:
There are multiple issues with this error which are described as following:
Here it can be seen that the lead dependency is mentioned as
path-to-regexp
as compared to subsequent job (mentioned on top) where the lead dependency isexpress
. Here the dependencies list is sorted alphabetically which is cause of this issue. Due to this mismatch the resulting job creates and erroneous situation that results in closing and creating a new PR. The ideal result in this situation should be to update the existing PR.Solution:
The fix intends to stop recreation of PRs if same version update is found in existing PR snapshot. It is seen that this issue exists for lead dependencies (first in the group) right now. The targeted version update can be matched with the one in pr snapshot, if the versions are a match, then a new PR creation can be avoided. i.e.First part of solution is to take security advisory dependency as a lead dependency, which is primary dependency on which the preceding PR was created. This solves the issue of inaccurate lead dependency.
The comparison of dependencies updated vs initial dependencies in job are now sorted in alphabetical order to accurately compare the two data sets (string array). This should resolve issue of inaccurate results in case same number of dependencies are updated but not in order.
Additional information:
To mitigate any issues that might come up with this fix, a feature flag lead_security_dependency is used to quickly roll back in case of any issues.
Telemetry data collection:
To assess the behaviour, telemetry log has been inserted at various places to collect information on impact of this issue. This is to conduct impact assessment of the issue later and facilitate next steps if required.
Plan of execution:
Anything you want to highlight for special attention from reviewers?
How will you know you've accomplished your goal?
We should see a larger drop in dropping and recreating new PRs on affected repos.
Checklist