-
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
Do not close a PR when it supersedes other groups #11382
Conversation
set += Array(dependency_names) | ||
names = Array(dependency_names) | ||
Dependabot.logger.info("Adding dependencies as handled: (#{names.join(', ')}).") | ||
set += names |
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.
This method can be simplified to avoid redundant variables (set
and names
) and directly update the handled dependencies. Here's a suggestion:
def add_handled_dependencies(dependency_names)
assert_current_directory_set!
@handled_dependencies[@current_directory] ||= Set.new
names = Array(dependency_names)
Dependabot.logger.info("Adding dependencies as handled: (#{names.join(', ')}).")
@handled_dependencies[@current_directory] += names
end
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.
Ok done
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 also just found a solution to the original problem that I've committed in addition to the logging
849f618
to
5167305
Compare
527905f
to
e52e699
Compare
@@ -1,4 +1,21 @@ | |||
[ | |||
{ |
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.
Not sure why 2.0.0
did not exist here, but did elsewhere
Thank you so much @judocode ! |
@abdulapopoola @kbukum1 is anything else needed here? |
# also add dependencies that might be in the group, as a rebase would add them; | ||
# this avoids individual PR creation that immediately is superseded by a group PR supersede | ||
add_handled_dependencies(group.dependencies.map(&:name)) | ||
current_dependencies = group.dependencies.map(&:name).reject do |dep| | ||
excluding_dependencies.include?(dep) |
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.
@judocode ,
This exclusion logic applies globally without checking the directory or update version. This may prevent necessary updates in other directories or skip higher-version updates. See full discussion in PR comments: #11382 (review)
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.
🔹 Concern 1: Cross-directory Exclusion
The exclusion process is currently checking dependencies globally without considering which directory the PR was created for. However, dependencies in different directories may still need updates and should not be excluded incorrectly.
⚠️ Potential Issue
- A dependency in one directory may have an existing PR, but the same dependency in another directory could still require an update.
- Right now, dependencies are excluded without verifying if the PR exists for the same directory, which may prevent necessary updates.
🛠 Suggested Fix
✅ Directory-Specific Exclusion
- Identify PRs per directory and collect exclude dependencies only for that specific directory rather than applying exclusions globally.
🔹 Concern 2: Version-based Exclusion
When excluding dependencies, the logic does not check whether the proposed update is for the same version or a higher version.
⚠️ Potential Issue
- If the new update proposes a higher version, we should not exclude it, as it still requires an update.
- Right now, exclusions happen without verifying dependency version in the created PR and proposed new one
🛠 Suggested Fix
✅ Directory-Specific Exclusion
- We somehow needs to consider not only dependencies but their versions as well between existing PR and new one.
Would love to hear your thoughts on these! 🚀
CC: @abdulapopoola
@kbukum1 To the 2nd point: You cannot know the version at this point. You can only know whether a dependency should be in a group, then the version check process will either include/exclude it based on the version. Which in this case, if you have overlapping groups, this update at least makes it possible and will be predictable, which is better than no update because of flawed logic closing PRs. |
Thanks for pointing that out. I will re-review it soon. |
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.
Revoking approval due to a concern. Re-reviewing.
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.
LGTM. Thanks for the contribution! 🎉
✅ Review Summary
-
Concern 1 (Cross-directory Exclusion): Valid issue, and it's correctly addressed.
- The fix ensures that dependencies are marked as handled only within the correct directory, preventing unintended exclusions across different directories.
-
Concern 2 (Version-based Exclusion): Not an issue.
- Dependencies should always be included in the refresh process regardless of version, as the update process itself determines whether a higher version is available and applies the update accordingly.
Just one last thing—since this is a core change, I’m adding a feature flag on our API so we can manage the rollout. Can you apply the feature flag to your changes? Feature Flag Name:
How to Use the Feature FlagFeature Flag Check Condition:You can check whether the feature flag is enabled using: # enable can be true or false.
enable = Dependabot::Experiments.enabled?(:allow_refresh_for_existing_pr_dependencies) For Specs:When writing or updating tests, you can stub the feature flag as follows: RSpec.describe YourSpecs do
...
before do
...
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:allow_refresh_for_existing_pr_dependencies)
.and_return(allow_refresh_for_existing_pr_dependencies)
end
...
end Note: Other specs may also require this feature flag if it hits the place where you used the feature flag. Let me know if you have any questions! 🚀 |
I did update feature flag checks to be on safe side. I will deploy it today after the pipeline succeed. But if you see any issue please let me know. |
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 fix is moved behind a feature flag for a gradual rollout. Since this change affects the core, we’ll monitor it in production and progressively roll it out to 100%.
@judocode CC: @abdulapopoola |
What are you trying to accomplish?
Prevent this issue, which, in summary:
Anything you want to highlight for special attention from reviewers?
I added an optional param to
mark_group_handled
calledexcluding_dependencies
, which should work as advertised, and will avoid the exclusion if the dependency is in an existing PR. Also, this should maintain current behavior of closing a PR when a dep exists in more than 1 PR.I only used this optional param in RefreshGroupUpdatePullRequest, and there are 2 other uses in GroupUpdateAllVersions. We may consider adding
excluding_dependencies
there as well, but I am not familiar with that path.How will you know you've accomplished your goal?
I have added a new test along with fixtures that demonstrates this new functionality works. Also, previous functionality and tests are maintained, which include an existing test that will close a PR if it sees a dependency exists in 2 PRs.
Checklist