Fix duplicate updated dependencies in multi-directory group refresh#15098
Merged
Conversation
…ltering - Guard against nil dependency.directory to avoid breaking ecosystems that don't populate the directory attribute - Add unit tests covering: matching directory, differing directory, nil directory, single-directory regression, handled dependencies, and group refresh override
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a bug in grouped refresh jobs for multi-directory repos where dependencies from other directories were being re-processed, producing duplicate “updated dependencies” (e.g., 27 instead of 9 in a 3×3 Terraform monorepo). The fix scopes dependency processing to the currently active directory during compile_all_dependency_changes_for.
Changes:
- Add directory-aware filtering in
GroupUpdateCreation#skip_dependency?to prevent cross-directory dependency processing during multi-dir group runs. - Add an end-to-end updater spec reproducing the multi-directory duplication scenario and asserting correct updated dependency counts / uniqueness.
- Add unit specs covering
skip_dependency?behavior for matching/mismatching directories, nil directories, handled deps, and refresh override behavior.
Show a summary per file
| File | Description |
|---|---|
| updater/lib/dependabot/updater/group_update_creation.rb | Adds directory-based skip logic to prevent cross-directory contamination in multi-dir group runs. |
| updater/spec/dependabot/updater/operations/refresh_group_update_pull_request_multi_dir_spec.rb | New end-to-end spec that reproduces the duplication bug and asserts correct behavior in a multi-dir refresh. |
| updater/spec/dependabot/updater/group_update_creation_spec.rb | Adds unit coverage for the new directory filtering behavior and related regressions. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 1
Use Pathname#cleanpath to normalize both dependency.directory and job.source.directory before comparing, consistent with the pattern used elsewhere in this file (e.g., existing_pr_covers_job_directories?). This prevents incorrectly skipping dependencies when directories contain equivalent but differently-formatted paths like '/app/./config/../config' vs '/app/config'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
thavaahariharangit
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
Fix a bug where multi-directory group refresh jobs produce duplicate updated dependencies. In a terraform monorepo with 3 directories each containing 3 providers, the refresh would report 27 updated dependencies (9 per directory due to cross-directory contamination) instead of the correct 9 (3 per directory).
The root cause is that
group.dependenciesaccumulates entries from all directories, andskip_dependency?didn't filter by directory. This PR adds a directory check to skip dependencies that don't belong to the currently-processed directory.Additionally, this PR adds a nil-safety guard to handle ecosystems that don't populate
dependency.directory, preventing them from being incorrectly skipped.Anything you want to highlight for special attention from reviewers?
The nil-safety guard (
dependency.directory && dependency.directory != job.source.directory) is important — without it, ecosystems that leavedependency.directoryasnilwould have all their dependencies skipped, sincenil != "/some/dir"evaluates totrue.How will you know you've accomplished your goal?
refresh_group_update_pull_request_multi_dir_spec.rb) demonstrates the bug scenario and verifies exactly 9 updated dependencies are produced (not 27).skip_dependency?cover: matching directory, differing directory, nil directory, single-directory regression, handled dependencies, and group refresh override.Checklist