Skip to content

fix(bundler): resolve catalog search at highest-precedence source before filtering#3331

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/catalog-search-precedence
Open

fix(bundler): resolve catalog search at highest-precedence source before filtering#3331
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/catalog-search-precedence

Conversation

@Quratulain-bilal

@Quratulain-bilal Quratulain-bilal commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

fixes #3330

what

CatalogStack.search() claimed a bundle id in seen only when the entry matched the query. so when the highest-precedence entry for an id did not match, a lower-precedence entry with the same id could match and be returned instead — even though resolve()/install always use the highest-precedence entry. search advertised a bundle the user could never actually install, contradicting the method's own docstring ("resolved at its highest-precedence source").

how

resolve every id to its highest-precedence entry first, then filter the resolved set by the query. search now agrees with resolve().

reproduction (fixed)

id shared in two catalogs — high-precedence "Alpha Tool", low-precedence "Searchable Widget":

  • before: search("widget") returned the shadowed low-precedence "Searchable Widget"
  • after: search("widget") returns nothing (that entry is not installable); search("alpha tool") returns the high-precedence entry

tests

added test_search_does_not_surface_a_shadowed_lower_precedence_entry. verified it fails on the current code (returns the shadowed entry) and passes with the fix; the existing test_search_dedupes_by_precedence_and_filters and the rest of the file still pass.

…ore filtering

CatalogStack.search() claimed a bundle id in `seen` only when the entry matched
the query. so when the highest-precedence entry for an id did NOT match, a
lower-precedence entry with the same id could match and be returned instead --
even though resolve()/install always use the highest-precedence entry. search
advertised a bundle (name, version, source) the user could never actually get,
contradicting the method's own docstring ("resolved at its highest-precedence
source").

resolve every id to its highest-precedence entry first, then filter the
resolved set by the query. search now agrees with resolve(): a query that only
a shadowed lower-precedence copy matches returns nothing.

add a regression test covering the shadowed-entry case.
@Quratulain-bilal Quratulain-bilal requested a review from mnriem as a code owner July 4, 2026 12:18
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.

Bug: catalog search can return a shadowed lower-precedence entry that install never uses

1 participant