Skip to content

chore: make dependency range alignment opt-in - #10228

Merged
cryptodev-2s merged 2 commits into
mainfrom
chore/make-dependency-range-alignment-opt-in
Sep 14, 2026
Merged

cryptodev-2s merged 2 commits into
mainfrom
chore/make-dependency-range-alignment-opt-in

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Explanation

Follow up to #10225, addressing review feedback on it.

#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 #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 #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)
  • 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 (no published package is touched)
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Only changes Yarn constraint fix behavior for monorepo manifest consistency; no runtime package code or published APIs.

Overview
Reverts the post-#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.

Reviewed by Cursor Bugbot for commit cb57bdb. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s cryptodev-2s self-assigned this Sep 14, 2026
@cryptodev-2s
cryptodev-2s requested a review from mcmire September 14, 2026 14:37
@cryptodev-2s
cryptodev-2s marked this pull request as ready for review September 14, 2026 14:38
@cryptodev-2s
cryptodev-2s force-pushed the chore/make-dependency-range-alignment-opt-in branch from be87913 to 797ac50 Compare September 14, 2026 14:38

@mcmire mcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks better, but do we also need to tell Dependabot to set this environment variable somehow?

Comment thread yarn.config.cjs Outdated
@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

This looks better, but do we also need to tell Dependabot to set this environment variable somehow?

Yes I will use the env variable in an upcoming PR

@mcmire mcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Sep 14, 2026
Merged via the queue into main with commit 9862deb Sep 14, 2026
338 checks passed
@cryptodev-2s
cryptodev-2s deleted the chore/make-dependency-range-alignment-opt-in branch September 14, 2026 16:58
pull Bot pushed a commit to Reality2byte/core that referenced this pull request Sep 15, 2026
## Explanation

Dependabot's pull requests cannot merge on their own. Its security
updates walk manifests one at a time rather than treating the Yarn
workspace as one project, so a dependency ends up with different ranges
in different packages and `yarn constraints` fails. It also does not
deduplicate `yarn.lock` and does not write changelog entries. MetaMask#10147,
MetaMask#10157, MetaMask#10177 and MetaMask#9369 are all stuck on this.

This adds a workflow that repairs all three and pushes the result back.
It runs `yarn constraints --fix` with `ALIGN_DEPENDENCY_RANGES=true`
(the opt in from MetaMask#10228, whose only intended caller is this workflow),
reinstalls, deduplicates, then runs the changelog fixer that already
exists. Order matters: aligning ranges rewrites manifests but leaves
`yarn.lock` stale.

It also adds `@lavamoat/*` to the npm allowlist. Both that and
`@metamask/*` are already in `npmPreapprovedPackages`, so neither can
trip the Yarn age gate during the repair install. Note that `allow` only
governs version updates, so the workflow will also act on security pull
requests for other packages, which is where the constraints failures
come from.

## Notes

- `pull_request`, not `pull_request_target`. Dependabot runs get a read
only token and no secrets, so the push is authorised by the OIDC
exchange, the same way snaps does it.
- `opened` and `reopened` only. The job pushes to the pull request
branch, so `synchronize` would loop.
- `[dependabot skip]` on the commit, otherwise Dependabot rebases and
wipes the repair.

## Verification

The workflow cannot run until it is on the default branch. Checked
locally:

| Check | Result |
| --- | --- |
| `constraints --fix` leaves `yarn.lock` stale | confirmed, hence the
reinstall step |
| `ALIGN_DEPENDENCY_RANGES=true yarn constraints --fix` on a split range
| aligns all 25 manifests, exit 0 |
| Default, without the variable | unchanged, still errors |

## References

Follows MetaMask#10225 and MetaMask#10228. Part of WPC-1161. Pattern borrowed from
MetaMask/snaps `update-pull-request.yml`.

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
(workflow and config only)
- [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**
> Changes are limited to Dependabot and CI workflow configuration; no
runtime application or auth logic is modified, though the workflow does
push commits to Dependabot branches via OIDC token exchange.
> 
> **Overview**
> Adds a GitHub Actions workflow that runs when **Dependabot** opens or
reopens a PR, then fixes the common reasons those PRs fail CI:
misaligned dependency ranges across the Yarn workspace, a stale or
duplicated **yarn.lock**, and missing changelog entries.
> 
> The job exchanges an OIDC token for write access (Dependabot’s default
token cannot push), runs **`yarn constraints --fix`** with
**`ALIGN_DEPENDENCY_RANGES=true`**, reinstalls with
**`--no-immutable`**, dedupes, and runs the existing
**`changelog:validate --fix`** flow before committing with
**`[dependabot skip]`** so Dependabot does not rebase away the repair.
It only listens to **`opened`** / **`reopened`** (not **`synchronize`**)
to avoid a push loop.
> 
> **Dependabot** config now allows version bumps for **`@lavamoat/*`**
npm packages, matching **`@metamask/*`**, so those updates can go
through the same repair path without Yarn age-gate issues during
install.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c90706d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants