Tighten update_versions.py regex to match <version> and <*.version> tags#49267
Draft
jeet1995 wants to merge 1 commit into
Draft
Tighten update_versions.py regex to match <version> and <*.version> tags#49267jeet1995 wants to merge 1 commit into
jeet1995 wants to merge 1 commit into
Conversation
…ersion> tags
The regex previously only matched version values inside <version>...</version>
elements. Custom Maven property tags like <scala-jackson.version>2.18.6
</scala-jackson.version> that carry valid {x-version-update} comments were
silently skipped, causing version drift and bannedDependencies failures
(see PR #49263 for the immediate fix).
The new regex uses a lookahead restricted to closing tags that are either
</version> or </something.version> (e.g. </scala-jackson.version>),
rejecting unrelated XML elements like </description> or </subversion>.
Python's re module does not support variable-length lookbehinds, so the
pattern uses a fixed-width lookbehind (?<=>) and places the restriction
entirely in the lookahead (?=</(?:[\w.\-]+\.)?version>).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
update_versions.pyusesexternal_dependency_version_regex(ineng/versioning/utils.py) to find and replace version values when processing{x-version-update}comments. The old regex:r'(?<=<version>).+?(?=</version>)'only matches content inside
<version>...</version>elements. Custom Maven property tags like:carry valid
{x-version-update}comments, but the regex substitution silently no-ops on them. This causedbannedDependenciesCI failures when Jackson was bumped to 2.18.7 (see PR #49263 for the immediate fix).Fix
Replace the regex with:
r'(?<=>)[^<]+(?=</(?:[\w.\-]+\.)?version>)'Component breakdown
(?<=>)>(Pythonrerequires fixed-width lookbehinds)[^<]+<)(?=</</(?:[\w.\-]+\.)?scala-jackson.)version>)version>— closing the tagWhat it matches / rejects
<version>2.18.7</version><scala-jackson.version>2.18.6</scala-jackson.version><scalatest.version>3.2.3</scalatest.version><description>Some text</description><subversion>1.0</subversion><!-- version 1.0 -->Python
relimitationAlan's suggested regex
(?<=<((?:[\w-.]+\.)?version)>).+?(?=<\/\1>)uses a variable-length lookbehind with a backreference, which Python'sremodule does not support (error: look-behind requires fixed-width pattern). The alternative places all variable-width logic in the lookahead, which has no such restriction.Validation
Ran
update_versions.py --sracross all 874 POM files:<version>only)azure-cosmos-spark_3/pom.xml,spark_3-5/pom.xml,spark_3-5_2-12/pom.xml,spark_4/pom.xmlAll 4 changes are
scala-jackson.versionproperty bumps from stale values (2.18.4 / 2.18.6) to 2.18.7 — identical to the manual fix in PR #49263.Known limitation
Tags like
<my-custom-property>(no.versionsuffix) would still be skipped. This is intentional — the script should only auto-update version-related properties.