renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.55k stars 2.3k forks source link

Autoclose not working on lock file maintenance PRs #7295

Open jspenguin2017 opened 4 years ago

jspenguin2017 commented 4 years ago

What Renovate type, platform and version are you using?

GitHub marketplace app.

Describe the bug

In one of my private repos, renovate created 3 PRs, 2 of which update dependencies and 1 updates the lock file. The 2 dependency update PRs were merged first, and the lock file PR becomes conflicted. I checked the checkbox to ask Renovate to rebase it, but Renovate simply unchecked the checkbox and left the PR conflicted.

Relevant debug logs

DEBUG: No updated lock files in branch
DEBUG: No files to commit
[...]
DEBUG: PR is configured for automerge
DEBUG: PR is conflicted
[...]
DEBUG: remainingBranches=
DEBUG: No branches to clean up

From: https://app.renovatebot.com/dashboard#github/jspenguin2017/SimpleGitGui2/231306146

To Reproduce

It unfortunately happened in a private repo, but this is what I believe to have happened:

  1. Renovate created a lock file maintenance PR
  2. Update the lock file by some other means (for example, a different Renovate PR, or simply manually update the lock file), leaving the lock file PR conflicted
  3. Ask Renovate to rebase the lock file maintenance PR

Expected result: Renovate realizes that the lock file is fully up to date and autoclose the PR Actual result: Renovate simply uncheck the rebase checkbox and do nothing

The private repo does not contain anything too important, so I can give you access if you want. The PR: https://github.com/jspenguin2017/SimpleGitGui2/pull/212

Additional context

Last time this happened (April 28), Renovate was able to autoclose the PR: https://github.com/jspenguin2017/Blog/pull/36

I initially thought that it is a regression from https://github.com/renovatebot/renovate/issues/3018, but that is from 2019 so maybe not...

jspenguin2017 commented 3 years ago

I managed to reproduce this in a public repo: https://github.com/jspenguin2017/TempTest0/pull/2

Reproduction steps

  1. Create a test repo
  2. Set the repo to be squash merge only (or select squash merge when merging PRs)
  3. Have Renovate to open 2 PRs:
    1. Refresh lock file
    2. Update a dependency but happens to also refresh the lock file (happens from time to time with electron and @types/node)
  4. Merge (via squash merge) the PR that updates dependency
  5. The lock file PR is now conflicted, but the lock file on the main branch is already up to date, so Renovate would leave the PR conflicted

To have Renovate open the 2 PRs

  1. Add the latest version of electron and the latest version minus 1 patch of @types/node
  2. Create the lock file with NPM
  3. Edit the lock file to have electron to use the @types/node that is 1 patch behind, like so: https://github.com/jspenguin2017/TempTest0/commit/43a9f24c3868d6a5a613550e4bdb7e7427d7de70

Other notes

If the lock file PR is conflicted, and the conflict could not be resolved because the main branch is already up to date, Renovate should close the PR.

github-actions[bot] commented 3 years ago

Thank you for providing a reproduction! :tada: :rocket:

The Renovate team will take a look at the reproduction repository. Once we confirm the provided repository reproduces the problem, the label will be changed to reproduction:confirmed.

PhilipAbed commented 2 years ago

You mention that the Lockfile is already updated by the dependency update, well that's true, but in this case you might get conflicted since the dependency update might not be the same as the lockfile maintenance result, now its outdated

There's no way to Auto close a conflicted PR, that doesn't make sense to me. if there's a conflict that means the File in the PR is not the same as the Main.. how will we know if we should close or not?

@rarkins @viceice can anyone explain this to me? do we Autoclose Conflicted PRs/branches?

jspenguin2017 commented 2 years ago

Hi @PhilipAbed , thank you for looking into this. If squash merge is being used, then it's possible for a file to be conflicted while being the same as the one in the main branch.

PhilipAbed commented 2 years ago

i was not able to reproduce the issue, because the moment you do such a change, renovate will automatically rebase the lock-file-maintenance pull request and create a new package-lock.json file.

now i was able to reproduce under certain circumstances, when i had npm<7 package.lock and then moved to npm 7+, but that is not relevant for renovate, as it is npm problem.

renovate is working as expected, maybe it was resolved on the way, but the issue is not reproducible on latest version. look at logs, rebasing PR after conflict automatically, and resolving the conflict:

DEBUG: processRepo() (repository=StinkyLord/7295-a)
DEBUG: Processing 1 branch: renovate/lock-file-maintenance (repository=StinkyLord/7295-a)
DEBUG: Calculated maximum PRs remaining this run (repository=StinkyLord/7295-a)
       "prsRemaining": 99
DEBUG: PullRequests limit = 99 (repository=StinkyLord/7295-a)
DEBUG: Calculated maximum branches remaining this run (repository=StinkyLord/7295-a)
       "branchesRemaining": 99
DEBUG: Branches limit = 99 (repository=StinkyLord/7295-a)
DEBUG: getBranchPr(renovate/lock-file-maintenance) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: findPr(renovate/lock-file-maintenance, undefined, open) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: getPrList success (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "pullsTotal": 12,
       "requestsTotal": 1,
       "apiQuotaAffected": true
DEBUG: Found PR #12 (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: branchExists=true (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: dependencyDashboardCheck=undefined (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: PR rebase requested=false (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Checking if PR has been edited (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Branch has not been modified (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "branchName": "renovate/lock-file-maintenance"
DEBUG: Found existing branch PR (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Checking schedule(null, null) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: No schedule defined (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Branch already exists (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: getBranchPr(renovate/lock-file-maintenance) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: findPr(renovate/lock-file-maintenance, undefined, open) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Found PR #12 (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: isBranchBehindBase=true (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "isBehind": true,
       "currentBranch": "main",
       "currentBranchSha": "b8b6b66730a9ce72dc128783cd78dc19a1713167"
DEBUG: Branch is behind base branch and needs rebasing (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Branch is unmodified, so can be rebased (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Using reuseExistingBranch: false (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Setting current branch to main (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: latest commit (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "branchName": "main",
       "latestCommitDate": "2022-08-28T17:48:55+03:00"
DEBUG: manager.getUpdatedPackageFiles() reuseExistingBranch=false (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: No package files need updating (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Getting updated lock files (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Writing package.json files (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "packageFiles": ["package.json"]
DEBUG: Ensuring package-lock.json is removed (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Writing any updated package files (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: npmrc file found in repository (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Writing updated .npmrc file to .npmrc (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Generating package-lock.json for . (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Spawning npm install to create ./package-lock.json (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Updating lock file only (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: No node constraint found - using latest (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Removing package-lock.json first due to lock file maintenance upgrade (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Executing command (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "command": "npm install --package-lock-only --no-audit --ignore-scripts"
DEBUG: exec completed (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "cmd": "npm install --package-lock-only --no-audit --ignore-scripts",
       "durationMs": 3709,
       "stdout": "\nup to date in 2s\n\n10 packages are looking for funding\n  run `npm fund` for details\n",
       "stderr": ""
DEBUG: package-lock.json needs updating (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Updated 1 lock files (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "updatedArtifacts": ["package-lock.json"]
DEBUG: Getting comments for #12 (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Found 0 comments (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: isBranchConflicted(main, renovate/lock-file-maintenance) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Setting git author name (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "gitAuthorName": "Self-hosted Renovate Bot"
DEBUG: Setting git author email (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "gitAuthorEmail": "philipabed451@gmail.com"
DEBUG: 1 file(s) to commit (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Preparing files for committing to branch renovate/lock-file-maintenance (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: git commit (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "deletedFiles": [],
       "ignoredFiles": [],
       "result": {
         "author": null,
         "branch": "renovate/lock-file-maintenance",
         "commit": "2aa66bc0dc3c12ea945bd5397933e61c724749ad",
         "root": false,
         "summary": {"changes": 1, "insertions": 31, "deletions": 53}
       }
DEBUG: Pushing branch renovate/lock-file-maintenance (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: git push (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "result": {
         "pushed": [],
         "ref": {"local": "refs/remotes/origin/renovate/lock-file-maintenance"},
         "remoteMessages": {"all": []}
       }
 INFO: Branch updated (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
       "commitSha": "2aa66bc0dc3c12ea945bd5397933e61c724749ad"
DEBUG: Checking if we can automerge branch (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: mergeStatus=no automerge (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Ensuring PR (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: There are 0 errors and 0 warnings (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: getBranchPr(renovate/lock-file-maintenance) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: findPr(renovate/lock-file-maintenance, undefined, open) (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Found PR #12 (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Found existing PR (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Processing existing PR (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: Pull Request #12 does not need updating (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: PR is not configured for automerge (repository=StinkyLord/7295-a, branch=renovate/lock-file-maintenance)
DEBUG: getBranchPr(renovate/lock-file-maintenance) (repository=StinkyLord/7295-a)
DEBUG: findPr(renovate/lock-file-maintenance, undefined, open) (repository=StinkyLord/7295-a)
DEBUG: Found PR #12 (repository=StinkyLord/7295-a)
DEBUG: Closing Dependency Dashboard (repository=StinkyLord/7295-a)
DEBUG: Removing any stale branches (repository=StinkyLord/7295-a)
DEBUG: config.repoIsOnboarded=true (repository=StinkyLord/7295-a)

This issue can be closed as not reproducible.

github-actions[bot] commented 2 years ago

Hi there,

You're reporting a problem with an outdated version of Renovate. Please try the latest version and tell us if that fixes your problem.

Good luck,

The Renovate team

jspenguin2017 commented 2 years ago

Hi @PhilipAbed , thank you for looking into this. I just tested this again, and I can still reproduce it. Please see the video recording below:

https://user-images.githubusercontent.com/7283682/187325910-f92183c9-6f58-45c1-a913-63c673d85f8a.mp4

PhilipAbed commented 2 years ago

Thanks @jspenguin2017, that helps a lot! it looks like a Caching issue, I will investigate further

aaronadamsCA commented 1 month ago

This is happening increasingly often for us. Ironically, the better we get at keeping our dependencies up to date with Renovate, the more often it happens.

Relevant log excerpt:

``` DEBUG: pnpm-lock.yaml hasn't changed (branch="renovate/lock-file-maintenance") DEBUG: No updated lock files in branch (branch="renovate/lock-file-maintenance") DEBUG: No changes to package files, skipping post-upgrade tasks (branch="renovate/lock-file-maintenance") DEBUG: isBranchConflicted(main, renovate/lock-file-maintenance) (branch="renovate/lock-file-maintenance") DEBUG: branch.isConflicted(): using git to calculate (branch="renovate/lock-file-maintenance") DEBUG: branch.isConflicted(): true (branch="renovate/lock-file-maintenance") DEBUG: No files to commit (branch="renovate/lock-file-maintenance") DEBUG: Setting current branch to main (branch="renovate/lock-file-maintenance") DEBUG: latest commit (branch="renovate/lock-file-maintenance") { "branchName": "main" "latestCommitDate": "2024-09-30T12:54:52+02:00" } DEBUG: Checking if we can automerge branch (branch="renovate/lock-file-maintenance") DEBUG: mergeStatus=no automerge (branch="renovate/lock-file-maintenance") DEBUG: Ensuring PR (branch="renovate/lock-file-maintenance") DEBUG: There are 0 errors and 0 warnings (branch="renovate/lock-file-maintenance") DEBUG: getBranchPr(renovate/lock-file-maintenance) (branch="renovate/lock-file-maintenance") DEBUG: findPr(renovate/lock-file-maintenance, undefined, open) (branch="renovate/lock-file-maintenance") DEBUG: Found PR #1222 (branch="renovate/lock-file-maintenance") DEBUG: Found existing PR (branch="renovate/lock-file-maintenance") DEBUG: PR cache matches but it has been edited in the past 24hrs, so processing PR (branch="renovate/lock-file-maintenance") DEBUG: Processing existing PR (branch="renovate/lock-file-maintenance") DEBUG: setPrCache() (branch="renovate/lock-file-maintenance") DEBUG: Pull Request #1222 does not need updating (branch="renovate/lock-file-maintenance") ```

As far as I can tell, this is the telltale line:

DEBUG: pnpm-lock.yaml hasn't changed (branch="renovate/lock-file-maintenance")

This means pnpm-lock.yaml is an exact match with the base branch, which presumably means the PR could be closed. Instead, it's left open and unchanged.

Nope, my mistake—I didn't realize rm pnpm-lock.yaml; pnpm i --lockfile-only will just rebuild the same lockfile as before! To actually rebuild the lockfile you also need to rm -rf node_modules/.

RahulGautamSingh commented 1 month ago

This means pnpm-lock.yaml is an exact match with the base branch, which presumably means the PR could be closed. Instead, it's left open and unchanged:

No, it means the lockfile which was generated in this run is same as the one generated on previous runs ie. same as the lockfile in the open PR