Skip to content

Fix Maven version parsing for non-numeric versions#339

Open
Vadim-Zenin wants to merge 1 commit into
pulp:mainfrom
Vadim-Zenin:fix-maven-nonnumeric-version-parsing
Open

Fix Maven version parsing for non-numeric versions#339
Vadim-Zenin wants to merge 1 commit into
pulp:mainfrom
Vadim-Zenin:fix-maven-nonnumeric-version-parsing

Conversation

@Vadim-Zenin

Copy link
Copy Markdown

Problem

MavenContentMixin.group_artifact_version_filename() decides whether a path
contains a version directory by matching the candidate segment against a
numeric-anchored regex (re.match(r"\d+...")). Maven versions are free-form,
so any version not starting with a digit — RELEASE, master-SNAPSHOT,
JIRA-tagged INT-7144.1.0.2, etc. — is misclassified: the version segment is
taken as the artifactId, version becomes None, and the upload fails with
a NOT NULL violation → HTTP 500 on PUT /pulp/maven/<distribution>/<path>.

Fixes #

Fix

The content type is already known upstream
(MavenRemote.get_remote_artifact_content_type() routes .xml* to
MavenMetadata, everything else to MavenArtifact). A binary artifact in
standard Maven layout always has a version directory, so the regex guess is
unnecessary and wrong there. This PR adds a version_present argument:

  • MavenArtifact passes version_present=True — version directory is always
    present, no guessing.
  • MavenMetadata and any other caller keep the existing best-effort detection
    (default version_present=None), so artifact-level maven-metadata.xml
    (which has no version directory) is unchanged.

No behavior change for numeric versions or for metadata; non-numeric artifact
versions now parse correctly.

Tests

Added pulp_maven/tests/unit/test_path_parsing.py covering numeric and
non-numeric versions plus the artifact-level-metadata (no-version) case.

Changelog

CHANGES/.bugfix added.

fixes pulp#338

Signed-off-by: Vadim Zenin <3098552+Vadim-Zenin@users.noreply.github.com>
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.

1 participant