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.62k stars 2.32k forks source link

autoReplace mistakenly updates both depName and version #8061

Closed rarkins closed 1 year ago

rarkins commented 3 years ago
DEBUG: Using RE2 as regex engine
DEBUG: Parsing configs
DEBUG: File config
       "config": {
         "autodiscover": false,
         "platform": "bitbucket",
         "gitAuthor": "Renovate Bot <listserv@groups.company.com>",
         "onboarding": false,
         "dryRun": false,
         "repositories": ["organization/my-repo"]
       }
DEBUG: CLI config
       "config": {}
DEBUG: Env config
       "config": {
         "hostRules": [
           {"hostType": "github", "domainName": "github.com", "token": "***********"}
         ],
         "baseDir": "/scratch",
         "logLevel": "debug",
         "username": "username",
         "password": "***********"
       }
DEBUG: Combined config
       "config": {
         "autodiscover": false,
         "platform": "bitbucket",
         "gitAuthor": "Renovate Bot <listserv@groups.company.com>",
         "onboarding": false,
         "dryRun": false,
         "repositories": ["organization/my-repo"],
         "hostRules": [
           {"hostType": "github", "domainName": "github.com", "token": "***********"}
         ],
         "baseDir": "/scratch",
         "logLevel": "debug",
         "username": "username",
         "password": "***********"
       }
 WARN: Bitbucket: missing 'account' scope for password
DEBUG: Using configured gitAuthor (Renovate Bot <listserv@groups.company.com>)
DEBUG: Using configured baseDir: /scratch
DEBUG: Using cacheDir: /scratch/cache
DEBUG: Initializing Renovate internal cache into /scratch/cache/renovate/renovate-cache-v1
DEBUG: Commits limit = null
 INFO: Repository started (repository=organization/my-repo)
       "renovateVersion": "24.5.1"
DEBUG: Using localDir: /scratch/repos/bitbucket/organization/my-repo (repository=organization/my-repo)
DEBUG: initRepo("organization/my-repo") (repository=organization/my-repo)
DEBUG: organization/my-repo owner = cloudcoreo (repository=organization/my-repo)
DEBUG: resetMemCache() (repository=organization/my-repo)
DEBUG: checkOnboarding() (repository=organization/my-repo)
DEBUG: isOnboarded() (repository=organization/my-repo)
DEBUG: findFile(renovate.json) (repository=organization/my-repo)
DEBUG: Initializing git repository into /scratch/repos/bitbucket/organization/my-repo (repository=organization/my-repo)
DEBUG: git clone completed (repository=organization/my-repo)
       "durationMs": 3524
DEBUG: latest commit (repository=organization/my-repo)
       "latestCommitDate": "2020-12-16T18:02:46-08:00"
DEBUG: Setting git author name (repository=organization/my-repo)
       "gitAuthorName": "Renovate Bot"
DEBUG: Setting git author email (repository=organization/my-repo)
       "gitAuthorEmail": "listserv@groups.company.com"
DEBUG: config file exists (repository=organization/my-repo)
DEBUG: Issues are disabled - cannot ensureIssueClosing (repository=organization/my-repo)
DEBUG: Repo is onboarded (repository=organization/my-repo)
DEBUG: Found renovate.json config file (repository=organization/my-repo)
DEBUG: Repository config (repository=organization/my-repo)
       "fileName": "renovate.json",
       "config": {
         "regexManagers": [
           {
             "fileMatch": ["(^|/)k8s/.*\\.ya?ml$"],
             "matchStrings": [
               "image:\\s*\\'?\\\"?(?<depName>[^:]+):(?<currentValue>[^\\s\\'\\\"]+)\\'?\\\"?\\s*"
             ],
             "datasourceTemplate": "docker",
             "versioningTemplate": "docker"
           }
         ],
         "packageRules": [
           {"paths": ["**/*"], "enabled": false},
           {
             "paths": ["k8s/base/defaults.*"],
             "packagePatterns": [".*"],
             "additionalBranchPrefix": "{{parentDir}}-",
             "enabled": true
           },
           {
             "paths": ["k8s/overlays/*/values.*"],
             "packagePatterns": [".*"],
             "additionalBranchPrefix": "{{parentDir}}-",
             "enabled": true
           }
         ],
         "enabledManagers": ["regex"]
       }
DEBUG: migrateAndValidate() (repository=organization/my-repo)
DEBUG: No config migration necessary (repository=organization/my-repo)
DEBUG: massaged config (repository=organization/my-repo)
       "config": {
         "regexManagers": [
           {
             "fileMatch": ["(^|/)k8s/.*\\.ya?ml$"],
             "matchStrings": [
               "image:\\s*\\'?\\\"?(?<depName>[^:]+):(?<currentValue>[^\\s\\'\\\"]+)\\'?\\\"?\\s*"
             ],
             "datasourceTemplate": "docker",
             "versioningTemplate": "docker"
           }
         ],
         "packageRules": [
           {"paths": ["**/*"], "enabled": false},
           {
             "paths": ["k8s/base/defaults.*"],
             "packagePatterns": [".*"],
             "additionalBranchPrefix": "{{parentDir}}-",
             "enabled": true
           },
           {
             "paths": ["k8s/overlays/*/values.*"],
             "packagePatterns": [".*"],
             "additionalBranchPrefix": "{{parentDir}}-",
             "enabled": true
           }
         ],
         "enabledManagers": ["regex"]
       }
DEBUG: migrated config (repository=organization/my-repo)
       "config": {
         "regexManagers": [
           {
             "fileMatch": ["(^|/)k8s/.*\\.ya?ml$"],
             "matchStrings": [
               "image:\\s*\\'?\\\"?(?<depName>[^:]+):(?<currentValue>[^\\s\\'\\\"]+)\\'?\\\"?\\s*"
             ],
             "datasourceTemplate": "docker",
             "versioningTemplate": "docker"
           }
         ],
         "packageRules": [
           {"paths": ["**/*"], "enabled": false},
           {
             "paths": ["k8s/base/defaults.*"],
             "packagePatterns": [".*"],
             "additionalBranchPrefix": "{{parentDir}}-",
             "enabled": true
           },
           {
             "paths": ["k8s/overlays/*/values.*"],
             "packagePatterns": [".*"],
             "additionalBranchPrefix": "{{parentDir}}-",
             "enabled": true
           }
         ],
         "enabledManagers": ["regex"]
       }
DEBUG: Found repo ignorePaths (repository=organization/my-repo)
       "ignorePaths": ["**/node_modules/**", "**/bower_components/**"]
DEBUG: detectSemanticCommits() (repository=organization/my-repo)
DEBUG: getCommitMessages (repository=organization/my-repo)
DEBUG: Semantic commits detection: unknown (repository=organization/my-repo)
DEBUG: No semantic commits detected (repository=organization/my-repo)
DEBUG: Setting branchPrefix: renovate/ (repository=organization/my-repo)
DEBUG: No vulnerability alerts found (repository=organization/my-repo)
DEBUG: processRepo() (repository=organization/my-repo)
DEBUG: No baseBranches (repository=organization/my-repo)
DEBUG: extract() (repository=organization/my-repo)
DEBUG: Setting current branch to master (repository=organization/my-repo)
DEBUG: latest commit (repository=organization/my-repo)
       "branchName": "master",
       "latestCommitDate": "2020-12-16T18:02:46-08:00"
DEBUG: Applying enabledManagers filtering (repository=organization/my-repo)
DEBUG: Using file match: (^|/)k8s/.*\.ya?ml$ for manager regex (repository=organization/my-repo)
DEBUG: Matched 6 file(s) for manager regex: k8s/base/defaults.yaml, k8s/base/namespace.yaml, k8s/base/service-account.yaml, k8s/overlays/dev-00/values.yaml, k8s/overlays/prd-00/values.yaml, k8s/overlays/stg-01/values.yaml (repository=organization/my-repo)
DEBUG: Found regex package files (repository=organization/my-repo)
DEBUG: Found 1 package file(s) (repository=organization/my-repo)
 INFO: Dependency extraction complete (repository=organization/my-repo)
       "baseBranch": "master",
       "stats": {
         "managers": {"regex": {"fileCount": 1, "depCount": 1}},
         "total": {"fileCount": 1, "depCount": 1}
       }
DEBUG: Using Basic auth for docker registry my-repository (repository=organization/my-repo)
DEBUG: getLabels(https://111111111111.dkr.ecr.us-east-1.amazonaws.com, my-repository, latest) (repository=organization/my-repo)
DEBUG: getManifestResponse(https://111111111111.dkr.ecr.us-east-1.amazonaws.com, my-repository, latest) (repository=organization/my-repo)
DEBUG: Using Basic auth for docker registry my-repository (repository=organization/my-repo)
DEBUG: Using Basic auth for docker registry my-repository (repository=organization/my-repo)
DEBUG: Package releases lookups complete (repository=organization/my-repo)
       "baseBranch": "master"
DEBUG: packageFiles with updates (repository=organization/my-repo)
       "config": {
         "regex": [
           {
             "packageFile": "k8s/base/defaults.yaml",
             "manager": "regex",
             "deps": [
               {
                 "depName": "111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository",
                 "currentValue": "1",
                 "datasource": "docker",
                 "versioning": "docker",
                 "replaceString": "image: \"111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository:1\"\n\n",
                 "depIndex": 0,
                 "updates": [
                   {
                     "fromVersion": "1",
                     "toVersion": "42",
                     "newValue": "42",
                     "newMajor": 42,
                     "newMinor": null,
                     "updateType": "major",
                     "isSingleVersion": true,
                     "newVersion": "42"
                   }
                 ],
                 "warnings": [],
                 "fixedVersion": "1",
                 "dockerRegistry": "https://111111111111.dkr.ecr.us-east-1.amazonaws.com",
                 "dockerRepository": "my-repository"
               }
             ],
             "matchStrings": [
               "image:\\s*\\'?\\\"?(?<depName>[^:]+):(?<currentValue>[^\\s\\'\\\"]+)\\'?\\\"?\\s*"
             ]
           }
         ]
       }
DEBUG: branchifyUpgrades (repository=organization/my-repo)
DEBUG: 1 flattened updates found: 111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository (repository=organization/my-repo)
DEBUG: Returning 1 branch(es) (repository=organization/my-repo)
DEBUG: config.repoIsOnboarded=true (repository=organization/my-repo)
DEBUG: processRepo() (repository=organization/my-repo)
DEBUG: Processing 1 branch: renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x (repository=organization/my-repo)
DEBUG: Calculated maximum PRs remaining this run (repository=organization/my-repo)
       "prsRemaining": 99
DEBUG: PullRequests limit = 99 (repository=organization/my-repo)
DEBUG: getBranchPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: findPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x, undefined, open) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: getPrList() (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Retrieving PR list (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Retrieved Pull Requests (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "length": 0
DEBUG: processBranch with 1 upgrades (repository=organization/my-repo, dependencies=111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Setting current branch to master (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: latest commit (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "branchName": "master",
       "latestCommitDate": "2020-12-16T18:02:46-08:00"
DEBUG: getBranchPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: findPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x, undefined, open) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: getPrList() (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: branchExists=false (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Branch has 1 upgrade(s) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: recreateClosed is false (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: findPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x, Update 111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository Docker tag to v42, !open) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: getPrList() (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: prAlreadyExisted=false (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Checking schedule(at any time, null) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: No schedule defined (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Branch needs creating (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Using reuseExistingBranch: false (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: manager.getUpdatedPackageFiles() (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "reuseExistingBranch": false,
       "branchName": "renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x"
DEBUG: Starting search at index 639 (repository=organization/my-repo, packageFile=k8s/base/defaults.yaml, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "depName": "111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository"
DEBUG: Found match at index 639 (repository=organization/my-repo, packageFile=k8s/base/defaults.yaml, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "depName": "111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository"
DEBUG: depName mismatch (repository=organization/my-repo, packageFile=k8s/base/defaults.yaml, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "manager": "regex",
       "currentDepName": "111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository",
       "newDepName": "111111111111.dkr.ecr.us-east-42.amazonaws.com/my-repository"
DEBUG: Contents updated (repository=organization/my-repo, packageFile=k8s/base/defaults.yaml, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "depName": "111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository"
DEBUG: Updated 1 package files (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: No updated lock files in branch (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: 1 file(s) to commit (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Committing files to branch renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
 INFO: Branch created (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "commitSha": "f9b659f"
DEBUG: Ensuring PR (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: There are 0 errors and 0 warnings (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: getBranchPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: findPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x, undefined, open) (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: getPrList() (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Creating PR (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "prTitle": "Update 111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository Docker tag to v42"
DEBUG: Creating PR (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "title": "Update 111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository Docker tag to v42",
       "base": "master"
 INFO: PR created (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "pr": 1,
       "prTitle": "Update 111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository Docker tag to v42"
DEBUG: Created Pull Request #1 (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: Checking #1 for automerge (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
       "automerge": false,
       "automergeType": "pr",
       "automergeComment": "automergeComment"
DEBUG: No automerge (repository=organization/my-repo, branch=renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x)
DEBUG: getBranchPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x) (repository=organization/my-repo)
DEBUG: findPr(renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x, undefined, open) (repository=organization/my-repo)
DEBUG: getPrList() (repository=organization/my-repo)
DEBUG: Removing any stale branches (repository=organization/my-repo)
DEBUG: config.repoIsOnboarded=true (repository=organization/my-repo)
DEBUG: Branch lists (repository=organization/my-repo)
       "branchList": [
         "renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x"
       ],
       "renovateBranches": [
         "renovate/base-111111111111.dkr.ecr.us-east-1.amazonaws.com-my-repository-42.x"
       ]
DEBUG: remainingBranches= (repository=organization/my-repo)
DEBUG: No branches to clean up (repository=organization/my-repo)
DEBUG: Issues are disabled - cannot ensureIssueClosing (repository=organization/my-repo)
DEBUG: Repository timing splits (milliseconds) (repository=organization/my-repo)
       "splits": {"init": 6696, "extract": 3159, "lookup": 14342, "update": 1797},
       "total": 26012
DEBUG: http statistics (repository=organization/my-repo)
       "hostStats": [
         "111111111111.dkr.ecr.us-east-1.amazonaws.com, 7 requests, 52ms request average, 0ms queue average",
         "api.bitbucket.org, 4 requests, 156ms request average, 0ms queue average"
       ],
       "totalRequests": 11
 INFO: Repository finished (repository=organization/my-repo)
       "durationMs": 26012
DEBUG: Renovate exiting

Originally posted by @caphrim007 in https://github.com/renovatebot/renovate/discussions/8054#discussioncomment-221190

rarkins commented 3 years ago

The autoReplace function appears to recognize the "depName mismatch" however the final update still has that mismatch. Maybe the file/branch was not reset correctly after the second update or something similar.

Or maybe we need the replaceString to be shorter somehow

viceice commented 3 years ago

What about if a manager can return a replace regex hint, so autoreplace can use that to replace in replacestring? 🤔

viceice commented 3 years ago

ah, i see, the sample depname is somehow confusing. instead of 111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository it should be 222222222222.dkr.ecr.us-east-1.amazonaws.com/my-repository

otherwise 111111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository would be replace to 4211111111111.dkr.ecr.us-east-1.amazonaws.com/my-repository. because regex manager replaces first occurence?

viceice commented 3 years ago

https://github.com/renovatebot/renovate/blob/6b1b34bf26eaf883c3dcf3062c04357a041de6b8/lib%2Fworkers%2Fbranch%2Fauto-replace.ts#L41-L51

missing return false; 🎉

caphrim007 commented 3 years ago

@viceice yeah, that leading set of 1's is a bit misleading. Here's a number that is more correct in my context (while still not disclosing anything sensitive).

883407545824.dkr.ecr.us-east-1.amazonaws.com/my-repository

became

883407545824.dkr.ecr.us-east-42.amazonaws.com/my-repository
caphrim007 commented 3 years ago

I dont have an account with 1's in the AWS account portion....but if the code was replacing my 1 in us-east-1, then I wouldn't be surprised (now) to also see it replace the leading 1's. Maybe it's enough for my issue to suggest it was replacing all instances of the current value instead of the one that was specifically the tag (after the colon)

setchy commented 1 year ago

@rarkins @viceice - I think this may be resolved now. WDYT?