Skip to content

fix: match repodata records by file name - #2454

Open
puneetdixit200 wants to merge 3 commits into
conda:mainfrom
puneetdixit200:fix/1721-path-file-name
Open

fix: match repodata records by file name#2454
puneetdixit200 wants to merge 3 commits into
conda:mainfrom
puneetdixit200:fix/1721-path-file-name

Conversation

@puneetdixit200

@puneetdixit200 puneetdixit200 commented May 21, 2026

Copy link
Copy Markdown

Description

Fixes #1721

fn constraints were parsed into MatchSpec, but were not checked when matching MatchSpec or NamelessMatchSpec against a RepoDataRecord. That allowed a path-style spec such as fn=file:///.../package.conda to behave like a name-only match instead of selecting by the record's archive filename.

This adds RepoDataRecord filename matching and treats URL/path fn values as their basename, so a local path dependency can match package-...conda while still rejecting a different archive filename.

How Has This Been Tested?

Red check before implementation:

  • cargo test -p rattler_conda_types test_file_name_matches_repodata_identifier -- --nocapture failed because fn=other-1.0-py37_0.conda still matched the record.

Green checks after implementation:

  • cargo test -p rattler_conda_types test_file_name_matches_repodata_identifier -- --nocapture
  • cargo test -p rattler_conda_types --lib
  • cargo fmt --all -- --check
  • cargo clippy -p rattler_conda_types --all-targets -- -D warnings
  • git diff --check

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: OpenAI GPT-5.5 was used to inspect the matchspec/repodata matching path, add the regression test and implementation, and draft this PR text. The changes and tests were reviewed and run locally.

Checklist:

  • I have performed a self-review of my own code
  • I have added sufficient tests to cover my changes.

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

is this also what conda does?

Comment thread crates/rattler_conda_types/src/match_spec/mod.rs Outdated
@puneetdixit200

Copy link
Copy Markdown
Author

I checked conda's current MatchSpec/PackageRecord path. MatchSpec.match() iterates every match component and compares it against the same field on the package record, and fn is a PackageRecord field. When a record only has a URL, conda derives fn from Channel(url).package_filename; on the spec side, MatchSpec.fn normalizes fn/url through basename(...).

So yes, this is intended to match conda behavior: a spec like fn=file:///.../pkg.conda is compared as the archive filename, not treated as a name-only match.

Refs I checked:

@puneetdixit200

Copy link
Copy Markdown
Author

Addressed in the follow-up commits. The current implementation no longer parses a URL for fn matching; it strips query/fragment text and takes the basename with string slicing. I also added a comment documenting that this mirrors conda's MatchSpec.fn/PackageRecord.fn filename semantics.

@puneetdixit200

Copy link
Copy Markdown
Author

Addressed the URL parsing concern in the current head: file_name_matches now strips query/fragment and takes the basename with string operations instead of calling Url::parse during matching. I also reran cargo test -p rattler_conda_types test_file_name_matches_repodata_identifier locally and it passes.

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.

file_name not correctly set when using { path = "..." } in pixi.toml

2 participants