chore: make the dependency consistency constraint auto-fixable - #10225
Merged
Conversation
cryptodev-2s
force-pushed
the
fix/auto-align-inconsistent-dependency-ranges
branch
from
September 14, 2026 12:11
d3c0649 to
f3d6043
Compare
cryptodev-2s
enabled auto-merge
September 14, 2026 12:26
Mrtenz
approved these changes
Sep 14, 2026
cryptodev-2s
deleted the
fix/auto-align-inconsistent-dependency-ranges
branch
September 14, 2026 12:34
This was referenced Sep 14, 2026
cryptodev-2s
added a commit
to cryptodev-2s/core
that referenced
this pull request
Sep 14, 2026
## Explanation Follow up to MetaMask#10225, addressing review feedback on it. MetaMask#10225 made the dependency range consistency constraint auto-fixable, which also made it fixable from `yarn lint:fix`. That risks a team hitting a constraints error, reaching for `yarn lint:fix` to clear it, and folding a monorepo-wide dependency bump into an unrelated pull request. Upgrades should stay in their own Dependabot pull requests. This makes the alignment opt in and off by default. Every local invocation now behaves exactly as it did before MetaMask#10225, same error, same wording. Only CI repairing a bot's pull request will opt in. The mechanism is an environment variable rather than a flag because `yarn constraints` is a Yarn builtin and rejects anything other than `--fix` and `--json`: ``` $ yarn constraints --fix --align Unknown Syntax Error: Unsupported option name ("--align"). ``` There is deliberately no package script wrapping it. A convenient front door is what would tempt someone into bundling an upgrade into unrelated work, which is the thing being fixed. ## Verification | Case | Result | | --- | --- | | Default, one package bumped | errors with "Pick one", no other manifest rewritten | | `ALIGN_DEPENDENCY_RANGES=true` | aligns all 25 manifests, exit 0 | | Clean tree, either mode | passes, nothing modified | | Incomparable range (`npm:uuid@^14.0.2`) | errors regardless of the variable | ## References Follows MetaMask#10225. Part of WPC-1161. ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate (no harness exists for `yarn.config.cjs`) - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) (no published package is touched) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Only changes Yarn constraint fix behavior for monorepo manifest consistency; no runtime package code or published APIs. > > **Overview** > Reverts the post-MetaMask#10225 behavior where **`yarn constraints --fix`** (including via **`yarn lint:fix`**) could automatically align mismatched semver ranges across workspaces to the highest range. **By default**, inconsistent dependency ranges again surface only the existing **"Pick one"** error with no manifest rewrites. > > **Opt-in auto-alignment** is gated on **`ALIGN_DEPENDENCY_RANGES=true`**, intended for CI that repairs Dependabot PRs—not a CLI flag (Yarn’s builtin rejects extra options) and not a package script. **Non-comparable ranges** (aliases, protocols, dist tags) still always error, with or without the env var. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cb57bdb. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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.
Explanation
expectConsistentDependenciesAndDevDependenciesrequires every workspace to use the same version range for a dependency, but it reports throughdependency.error(), which Yarn has no way to repair. Soyarn constraints --fixdoes nothing for it and a human has to hand edit every manifest.That mostly hurts on Dependabot PRs. Dependabot's security updates walk manifests one at a time rather than treating the Yarn workspace as one project, so they routinely bump a dependency in some packages and not others. The result is a red build on a change nobody actually has to think about. PR #10147 is a good example: it bumped
uuidin 22 packages,uuidis declared in 24, and the two stragglers fail constraints. Same story on #10157, #10177 and #9369, which is a large part of whyuuidalone accounts for 25 of our open Dependabot alerts.This makes the rule fixable. When every conflicting range is plain semver, the one permitting the highest minimum version wins and
dependency.update()aligns the rest, soyarn constraints --fix(whichyarn lint:fixalready runs) repairs a partial bump on its own.The previous docstring said it is impossible to compare NPM version ranges, so let the user decide. That is still true in general, and the fallback is unchanged: anything that is not a plain semver range, so aliases like
npm:foo@^1.0.0, protocols likeworkspace:^, or dist tags, still produces the original "Pick one" error with the same wording. The narrower claim here is only thatsemver.minVersion()is comparable when every range has one, andgetHighestRangebails out the moment one doesn't.Nothing else in the file changes.
ALLOWED_INCONSISTENT_DEPENDENCIESand its filter behave exactly as before.Verification
There is no test harness for
yarn.config.cjs, so I verified against the monorepo itself:uuidbumped in one package only--fixaligned all 25 manifests, re-check cleannpm:uuid@^14.0.2^8.0.0^9.0.1, not propagated downThe last one is the safety property worth calling out: a wrong range in one manifest gets corrected upward rather than dragging every other package backwards.
Worth knowing that
--fixalso reaches the rootpackage.json, which declares some of these dependencies too.Trade off
Aligning to the highest range is a real dependency change, not a formatting fix. One bump in one package can move the rest onto a new major, and
yarn lint:fixwill do that locally without asking. The argument for it is that the constraint already requires these to move together, so the only open question was who performs the alignment and in which direction, and aligning downward would mean reverting security fixes.References
Part of WPC-1161. This is the first step toward dropping the
@metamask/*allowlist in.github/dependabot.ymlso we can bump everything, not just MetaMask packages. The follow up is a workflow on bot PRs that runsyarn constraints --fix,yarn dedupeandyarn changelog:validate --checkDeps --fix, modelled on the one snaps already has inupdate-pull-request.yml.Related to #10147, #10157, #10177, #9369.
Checklist
yarn.config.cjs, see Verification above)