Skip to content

fix(config): normalize migrated package rule matchers#44452

Open
jonathanmorley wants to merge 3 commits into
renovatebot:mainfrom
cvent:codex/fix-package-rules-pattern-migration
Open

fix(config): normalize migrated package rule matchers#44452
jonathanmorley wants to merge 3 commits into
renovatebot:mainfrom
cvent:codex/fix-package-rules-pattern-migration

Conversation

@jonathanmorley

Copy link
Copy Markdown
Contributor

Changes

This addresses #43936.

In summary, the current matcher normalization causes some configurations to fail when evaluated against the recently tightened matcher validations.
This changes the normalization of matchers to comply with the new requirements.

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

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

The public repository:

@github-actions github-actions Bot requested a review from viceice July 9, 2026 15:54

@RahulGautamSingh RahulGautamSingh 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.

Nice fix on the core bug, but I think the normalization pass is over-scoped.

The real defect is narrow:

The old migration wrapped match-all patterns as regexes (/*/, !/*/), and validation rejects those because they fail to compile.

The two-line fix in migratePattern / migrateExcludePattern (emit * and !** instead) resolves that completely, since both are globs and skip the regex check.

Everything in normalizeRegexOrGlobMatchers / normalizeMatchers and the supporting Sets and predicates only collapses combinations that already pass validation:

['*', '!/foo/'] to ['!/foo/']
['**', 'foo'] to ['**']
['!**', 'foo'] to ['!**']

None of those trigger a validation error, so none of it is needed to fix the reported issue.

@jonathanmorley

Copy link
Copy Markdown
Contributor Author

I think there are two migration failures at play here, that are potentially getting conflated:

  1. Legacy match-all patterns can become invalid regex tokens, such as "*" becoming "/*/". The migratePattern / migrateExcludePattern changes fix this by emitting "*" and "!**".
  2. Migration can produce individually valid matchers that form an invalid array. The original reproduction is:
{
  "packagePatterns": ["*"],
  "excludePackagePatterns": ["some-package"]
}

Without normalization, that becomes:

{
  "matchPackageNames": ["*", "!/some-package/"]
}

regex-glob-matchers.ts rejects this because it contains * alongside another matcher.

@RahulGautamSingh

Copy link
Copy Markdown
Collaborator

Can we fix this by adding a helper function which after migration checks the failing case ie. that * pattern is not combined with others?

The current solution looks very bloated to me, and I don;t want it to be a maintenance issue in future.

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