feat: repair Dependabot pull requests automatically - #10231
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3f2ea68. Configure here.
mcmire
left a comment
There was a problem hiding this comment.
Makes sense, just left a few comments/suggestions.
| # Aligning ranges rewrites manifests but not the lockfile, so it has to be resolved again before deduplicating. | ||
| - name: Resolve the lockfile | ||
| run: yarn install --no-immutable |
There was a problem hiding this comment.
Will --no-immutable work here? My understanding is that we use this in workflows when we've updated the lockfile in Git but we want Yarn to install dependencies, and we don't want Yarn to update the lockfile anymore. However in this case we do need to update the lockfile (because we're changing versions of dependencies), so maybe we need to drop --no-immutable? (Also, if we rephrase this step as "apply dependency range updates" maybe we don't need the comment?)
| # Aligning ranges rewrites manifests but not the lockfile, so it has to be resolved again before deduplicating. | |
| - name: Resolve the lockfile | |
| run: yarn install --no-immutable | |
| - name: Apply dependency range updates | |
| run: yarn install |
There was a problem hiding this comment.
Actually why we can't useyarn install as ub the CI it defaults to --immutable and forbids lockfile changes, We need--no-immutable to allow this as the previous step we regenerate the lock.
There was a problem hiding this comment.
Oh, right, I got mixed up. Thanks.
| - name: Deduplicate the lockfile | ||
| run: yarn dedupe |
There was a problem hiding this comment.
Nit: We aren't deduplicating the lockfile per se, we're deduplicating the dependency tree, which the lockfile represents.
| - name: Deduplicate the lockfile | |
| run: yarn dedupe | |
| - name: Deduplicate dependency tree | |
| run: yarn dedupe |
| git config user.name 'MetaMask Bot' | ||
| git config user.email 'metamaskbot@users.noreply.github.com' |
There was a problem hiding this comment.
Nit: Since the token comes from metamask-ci do we want to use that instead? (this is copied from https://github.com/MetaMask/core-platform-metrics/blob/7b14be72749417587c6ab6b423b9455114292adc/.github/workflows/remove-dashboard-preview.yml#L49C1-L51C1)
| git config user.name 'MetaMask Bot' | |
| git config user.email 'metamaskbot@users.noreply.github.com' | |
| git config user.name "metamask-ci[bot]" | |
| git config user.email "271559518+metamask-ci[bot]@users.noreply.github.com" |
| jobs: | ||
| repair: | ||
| name: Repair constraints, lockfile and changelogs | ||
| if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.actor != 'metamask-ci[bot]' }} |
There was a problem hiding this comment.
Do you need to check that this doesn't come from metamask-ci? Is it enough to check that it comes from Dependabot?
| if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.actor != 'metamask-ci[bot]' }} | |
| if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} |
There was a problem hiding this comment.
Indeed its redundant and we don't use synchronise here

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 constraintsfails. It also does not deduplicateyarn.lockand does not write changelog entries. #10147, #10157, #10177 and #9369 are all stuck on this.This adds a workflow that repairs all three and pushes the result back. It runs
yarn constraints --fixwithALIGN_DEPENDENCY_RANGES=true(the opt in from #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 leavesyarn.lockstale.It also adds
@lavamoat/*to the npm allowlist. Both that and@metamask/*are already innpmPreapprovedPackages, so neither can trip the Yarn age gate during the repair install. Note thatallowonly 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, notpull_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.openedandreopenedonly. The job pushes to the pull request branch, sosynchronizewould 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:
constraints --fixleavesyarn.lockstaleALIGN_DEPENDENCY_RANGES=true yarn constraints --fixon a split rangeReferences
Follows #10225 and #10228. Part of WPC-1161. Pattern borrowed from MetaMask/snaps
update-pull-request.yml.Checklist
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 --fixwithALIGN_DEPENDENCY_RANGES=true, reinstalls with--no-immutable, dedupes, and runs the existingchangelog:validate --fixflow before committing with[dependabot skip]so Dependabot does not rebase away the repair. It only listens toopened/reopened(notsynchronize) 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.Reviewed by Cursor Bugbot for commit c90706d. Bugbot is set up for automated code reviews on this repo. Configure here.