Skip to content

fix: preserve channel priority for direct dependencies#2184

Open
mohitdebian wants to merge 8 commits intoconda:mainfrom
mohitdebian:fix-channel-priority-direct-deps
Open

fix: preserve channel priority for direct dependencies#2184
mohitdebian wants to merge 8 commits intoconda:mainfrom
mohitdebian:fix-channel-priority-direct-deps

Conversation

@mohitdebian
Copy link

@mohitdebian mohitdebian commented Mar 6, 2026

Fixes #1928

Problem

The repodata gateway filtered records for direct dependencies before they reached the solver. If a higher-priority channel contained the package but no version matching the spec, all records from that channel were removed. The solver then treated a lower-priority channel as the first channel containing the package.

Solution

Modify accumulate_records() so that when no records match the MatchSpec, records from the channel are still included. This allows the solver to detect channel ownership and correctly enforce strict channel priority.

Tests

Added regression test where:

  • Channel A (higher priority) contains only older versions
  • Channel B (lower priority) contains a newer version
  • Spec requires the newer version

With strict channel priority the solve now fails instead of selecting the lower-priority channel.

Fixes conda#1928

The repodata gateway filtered records for direct dependencies before
they reached the solver. If a higher-priority channel contained the
package but no version matching the spec, all records from that channel
were removed. The solver then treated a lower-priority channel as the
first channel containing the package.

Modify accumulate_records() so that when no records match the MatchSpec,
records from the channel are still included. This allows the solver to
detect channel ownership and correctly enforce strict channel priority.

Added regression test where:
- Channel A (higher priority) contains only older versions
- Channel B (lower priority) contains a newer version
- Spec requires the newer version

With strict channel priority the solve now correctly fails instead of
selecting the lower-priority channel.
Copy link
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downside is that we match twice now. Which is just wasted performance..

@mohitdebian
Copy link
Author

Thanks for pointing that out. I've updated the implementation so the matching is done in a single pass while keeping the same behavior when nothing matches

@mohitdebian mohitdebian requested a review from baszalmstra March 7, 2026 09:06
Copy link
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not what i meant. i meant that is a waste in the solver where we run all sorts of checks on records of which we know will never match. I think a better approach would be to change the input of solvertask so we know per channel the name it contains even though it might not contain records for that name

@mohitdebian
Copy link
Author

thanks for the clarification i've updated the implementation so the solver now knows which package names exist per channel instead of passing non matching records

@mohitdebian mohitdebian requested a review from baszalmstra March 7, 2026 19:16
@mohitdebian mohitdebian closed this Mar 7, 2026
@mohitdebian mohitdebian reopened this Mar 7, 2026
@baszalmstra
Copy link
Collaborator

This is not a good solution because it decouples the channel_package_names field from the available_packages field.

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.

Channel priority is not forced on direct dependencies

2 participants