Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(packageRules): evaluate confidence matcher first #23327

Merged

Conversation

Gabriel-Ladzaretti
Copy link
Collaborator

@Gabriel-Ladzaretti Gabriel-Ladzaretti commented Jul 12, 2023

Changes

Evaluate matchConfidence first when applying package rules.

applyPackageRules evaluates matchers in the order of insertion. It also returns early when any set matcher fails.
Therefore, when multiple matchers are set in a single packageRule, we might not check all set matchers, which can cause unwanted lookup and PR flip-flop.

Context

When scanning the following reproduction repository, we fail to abort run before performing lookup, although matchConfidence is used without credentials.
This in turn treated as LookupError as can be seen in the corresponding Dashboard.

Click to expand Logs
DEBUG: Found npm package files (repository=ladzaretti/pr-order-eval)
DEBUG: Found 1 package file(s) (repository=ladzaretti/pr-order-eval)
 INFO: Dependency extraction complete (repository=ladzaretti/pr-order-eval, baseBranch=main)
       "stats": {
         "managers": {"npm": {"fileCount": 1, "depCount": 1}},
         "total": {"fileCount": 1, "depCount": 1}
       }
ERROR: lookupUpdates error (repository=ladzaretti/pr-order-eval, packageFile=package.json)
       "currentDigest": undefined,
       "currentValue": "4.0.0",
       "datasource": "npm",
       "packageName": "lodash",
       "digestOneAndOnly": undefined,
       "followTag": null,
       "lockedVersion": undefined,
       "pinDigests": false,
       "rollbackPrs": false,
       "isVulnerabilityAlert": undefined,
       "updatePinnedDependencies": true,
       "unconstrainedValue": false,
       "err": {
         "validationMessage": "Missing credentials",
         "validationError": "The `matchConfidence` matcher in `packageRules` requires authentication. Please refer to the [documentation](https://docs.renovatebot.com
/configuration-options/#matchconfidence) and add the required host rule.",
         "message": "missing-api-credentials",
         "stack": "Error: missing-api-credentials\n    at MergeConfidenceMatcher.matches (C:\\projects\\ladzaretti-renovate\\lib\\util\\package-rules\\merge-confidenc
e.ts:20:21)\n    at matcherOR (C:\\projects\\ladzaretti-renovate\\lib\\util\\package-rules\\utils.ts:19:27)\n    at matchesRule (C:\\projects\\ladzaretti-renovate\\li
b\\util\\package-rules\\index.ts:17:30)\n    at applyPackageRules (C:\\projects\\ladzaretti-renovate\\lib\\util\\package-rules\\index.ts:74:9)\n    at filterInternalC
hecks (C:\\projects\\ladzaretti-renovate\\lib\\workers\\repository\\process\\lookup\\filter-checks.ts:54:40)\n    at lookupUpdates (C:\\projects\\ladzaretti-renovate\
\lib\\workers\\repository\\process\\lookup\\index.ts:276:37)\n    at async withLookupStats (C:\\projects\\ladzaretti-renovate\\lib\\workers\\repository\\process\\fetc
h.ts:29:18)\n    at async fetchDepUpdates (C:\\projects\\ladzaretti-renovate\\lib\\workers\\repository\\process\\fetch.ts:74:30)\n    at async C:\\projects\\ladzarett
i-renovate\\node_modules\\p-map\\index.js:57:22"
       }
DEBUG: PackageFiles.add() - Package file saved for base branch (repository=ladzaretti/pr-order-eval, baseBranch=main)


Expected Behavior

Raise a new warning issue whenever the matchConfidence PackageRules matcher is used without credentials.

As per:

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@Gabriel-Ladzaretti Gabriel-Ladzaretti changed the title evaluate confidence matcher first fix(packageRules): evaluate confidence matcher first Jul 12, 2023
@Gabriel-Ladzaretti Gabriel-Ladzaretti marked this pull request as ready for review July 12, 2023 14:01
@rarkins rarkins enabled auto-merge July 12, 2023 17:41
@rarkins rarkins added this pull request to the merge queue Jul 12, 2023
Merged via the queue into renovatebot:main with commit bbe9697 Jul 12, 2023
51 checks passed
@rarkins rarkins deleted the fix/package-rules-eval-order branch July 12, 2023 17:51
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 36.7.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants