Remove avoid_duplicate_updates_package_json FF from dependabot-core#14428
Conversation
|
@copilot please fix the failing npm_and_yarn ci test and the lint errors. |
Fixed in e8ed038:
|
There was a problem hiding this comment.
Pull request overview
Removes the avoid_duplicate_updates_package_json experiment flag and makes the previously “enabled” behavior the default for PackageJsonUpdater logic in the npm_and_yarn and bun ecosystems, along with corresponding spec cleanups/expectation updates.
Changes:
- Collapses feature-flag-gated
package.jsonno-op detection into a single unconditional guard (raiseonly when updating >1 unique dep name and content didn’t change). - Removes experiment stubbing/registration related to
avoid_duplicate_updates_package_jsonacross affected specs. - Updates a Yarn lockfile updater spec to expect
Dependabot::MisconfiguredToolingfor a misconfigured.yarnrc.ymlcase.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/package_json_updater.rb |
Removes experiment gating and simplifies the no-op content guard logic. |
bun/lib/dependabot/bun/file_updater/package_json_updater.rb |
Mirrors the same experiment removal and simplified guard logic as npm/yarn. |
npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater_spec.rb |
Removes stubbing for the removed experiment flag. |
npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/npm_lockfile_updater_spec.rb |
Removes stubbing for the removed experiment flag. |
npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater_spec.rb |
Removes stubbing for the removed experiment flag and updates expected error type for .yarnrc.yml misconfiguration. |
npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/package_json_updater_spec.rb |
Removes experiment register/unregister scaffolding around the multi-dependency behavior spec. |
bun/spec/dependabot/bun/file_updater_spec.rb |
Removes stubbing/resetting related to the removed experiment flag. |
| # most likely a transitive dependency which only needs an update in the lockfile. We avoid | ||
| # throwing an exception and let the update continue. |
There was a problem hiding this comment.
The comment claims we “avoid throwing an exception and let the update continue”, but the code still raises when content == new_content and unique_deps_count > 1. Please adjust the comment to reflect the actual behavior (no-op updates are only allowed when the update batch contains a single unique dependency name).
| # most likely a transitive dependency which only needs an update in the lockfile. We avoid | |
| # throwing an exception and let the update continue. | |
| # most likely a transitive dependency which only needs an update in the lockfile. We allow this | |
| # kind of no-op update only when updating a single unique dependency name; otherwise we raise. |
| allow(Dependabot::Experiments).to receive(:enabled?) | ||
| .with(:enable_private_registry_for_corepack).and_return(true) | ||
| allow(Dependabot::Experiments).to receive(:enabled?) | ||
| .with(:avoid_duplicate_updates_package_json).and_return(false) | ||
| allow(Dependabot::Experiments).to receive(:enabled?) | ||
| .with(:enable_private_registry_for_corepack).and_return(false) |
There was a problem hiding this comment.
In this before block, Dependabot::Experiments.enabled?(:enable_private_registry_for_corepack) is stubbed twice (first true, then false). The second stub overrides the first, so the true stub is dead code and makes the setup harder to reason about. Please remove the redundant stub or replace with a single stub that returns the intended value(s).
See below for a potential fix:
.with(:enable_private_registry_for_corepack).and_return(false)
end
after do
after do
| allow(Dependabot::Experiments).to receive(:enabled?) | ||
| .with(:enable_private_registry_for_corepack).and_return(true) | ||
| allow(Dependabot::Experiments).to receive(:enabled?) | ||
| .with(:avoid_duplicate_updates_package_json).and_return(false) | ||
| allow(Dependabot::Experiments).to receive(:enabled?) | ||
| .with(:enable_private_registry_for_corepack).and_return(false) |
There was a problem hiding this comment.
Dependabot::Experiments.enabled?(:enable_private_registry_for_corepack) is stubbed twice back-to-back (to true and then false). The second stub overrides the first, so the true stub is ineffective and confusing. Consider removing the redundant stub or using a single stub with the intended return value(s).
See below for a potential fix:
|
@copilot apply changes based on the comments in this thread |
Applied all three review comments in 74bb777:
|
Remove the feature flag from production code in both npm_and_yarn and bun PackageJsonUpdater, keeping the "enabled" behavior as the permanent path. Remove all related test mocks and experiment registrations. Co-authored-by: pavera <660677+pavera@users.noreply.github.com>
- Remove unnecessary rubocop:disable/enable Metrics/PerceivedComplexity - Convert if block to modifier style per Style/IfUnlessModifier - Update yarn_lockfile_updater_spec to expect MisconfiguredTooling (with the FF removed, single-dep scenarios no longer raise "Expected content to change!" — the yarn updater now correctly detects the misconfigured .yarnrc.yml) Co-authored-by: pavera <660677+pavera@users.noreply.github.com>
…json_updater.rb Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Update comment in bun PackageJsonUpdater to accurately describe the raise behavior (matches npm_and_yarn version) - Remove redundant enable_private_registry_for_corepack stub in file_updater_spec.rb (was stubbed true then overridden to false) - Remove same redundant stub in npm_lockfile_updater_spec.rb Co-authored-by: pavera <660677+pavera@users.noreply.github.com>
74bb777 to
9deb6eb
Compare
What are you trying to accomplish?
Remove the
avoid_duplicate_updates_package_jsonfeature flag, making its "enabled" behavior the permanent code path.The flag guarded logic that avoids raising
"Expected content to change!"when a dependency in the update batch is not present inpackage.json(e.g., a transitive dep only needing a lockfile update). With the flag removed, the checkcontent == new_content && unique_deps_count > 1is now unconditional.Anything you want to highlight for special attention from reviewers?
Production code (
npm_and_yarnandbunPackageJsonUpdater):unique_deps_count == 1(same dep name appearing multiple times, e.g. in bothdependenciesanddevDependencies), unchanged content is silently allowed — this is the duplicate/transitive dep case the flag was protectingrubocop:disable/enable Metrics/PerceivedComplexitydirectives since the simplified code no longer triggers the copnpm_and_yarnandbunPackageJsonUpdaterto accurately describe the raise behavior: no-op updates are tolerated for a single unique dependency name, but treated as unexpected when multiple unique deps are being updatedTest code (6 spec files):
allow(Experiments).to receive(:enabled?).with(:avoid_duplicate_updates_package_json)stubs fromfile_updater_spec,yarn_lockfile_updater_spec,npm_lockfile_updater_spec, andbun/file_updater_specExperiments.register/reset!blocks that were gating thepackage_json_updater_spectest — the test now exercises the behavior directly without experiment setupyarn_lockfile_updater_spectest for misconfigured.yarnrc.ymlto expectDependabot::MisconfiguredToolinginstead of"Expected content to change!"— with the FF removed, single-dep scenarios no longer early-exit with the generic error and instead correctly surface the real misconfiguration error from yarnenable_private_registry_for_corepackexperiment stubs infile_updater_specandnpm_lockfile_updater_specwhere the flag was stubbedtruethen immediately overridden tofalseHow will you know you've accomplished your goal?
Existing test suite passes, including the
"when updating multiple dependencies that results in 'package.json' update only once"spec which validates the preserved behavior, and the"with a missing double quotes token value in the .yarnrc.yml"spec which now validates the correctMisconfiguredToolingerror is raised.Checklist
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.