Repository navigation
Conversation
Implements AsyncCatalogsSearchClient and wires CatalogsSearchExtension so
GET/POST /catalogs/{catalog_id}/search search items bounded to a catalog's
descendant tree. Descendant collections are resolved with a single
recursive CTE over collections.content->'parent_ids' (UNION dedupes
poly-hierarchy paths and guarantees termination). Explicit `collections`
parameters are intersected with the allowed scope; fully out-of-scope
requests return 403 and unknown catalogs 404.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ndling
Adds GET/POST /catalogs/{catalog_id}/search endpoints that search items within a catalog's descendant tree. The scoped search delegates to the core client with an intersected collections filter. Empty-scope requests (all requested collections outside the catalog or an empty catalog) return an empty ItemCollection instead of errors. The self link in scoped results references the scoped route rather than global /search.
vincentsarago
approved these changes
Nov 23, 2026
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.
Technical Context
Description
Adds catalog-scoped item search:
GET/POST /catalogs/{catalog_id}/search, backed byCatalogsSearchExtensionandAsyncCatalogsSearchClientfromstac-fastapi-catalogs-extension>=1.1.0(already the required version). Enabled automatically wheneverENABLE_CATALOGS_EXTENSIONis on — no additional flag, matching how SFEOS wires it.How it works
CatalogsClientnow also implementsAsyncCatalogsSearchClient. Both scoped endpoints bound the search to the catalog's descendant tree:catalog_search_get/catalog_search_postintersect the caller'scollectionsfilter withget_all_descendant_collection_ids, then delegate toCoreCrudClient.get_search/post_search./search, so every enabled search extension (CQL2 filter, sort, fields, free text, token pagination) applies to scoped searches too.WITH RECURSIVEquery overcontent->'parent_ids'inCatalogsDatabaseLogic—UNIONdedup keeps poly-hierarchies correct and guarantees termination.CatalogsClientinstance is shared byCatalogsExtension,CatalogsTransactionExtension, andCatalogsSearchExtension(same pattern as SFEOS):Extensions.catalog_searchconstructs it withcore_clientinjected,Extensions.catalogreuses it — evaluated in that order ininstantiate_api.Semantics worth noting
collectionsomitted or[]→ the catalog's full scope (same as/searchtreating[]as "no constraint").collectionspartially or fully out of scope → silently intersected; an empty result returns200withfeatures: []— a filter that matches nothing, not an error.get_search:clean_search_argsstrips empty lists, which would silently turn the request into an unbounded global/search. Both endpoints short-circuit to an emptyItemCollectioninstead.404(validated inside the descendant walk).selflink on scoped results is rewritten to/catalogs/{id}/search; paging links already derive from the request URL and stay scoped, and POST next-bodies re-run the intersection.item-search,multi-tenant-catalogs/search) are advertised both globally and per-catalog viaapp.state.catalogs_conformance_classes.Tests
New coverage in
tests/extensions/test_catalogs.py: subtree/poly-hierarchy traversal, GET↔POST parity,collectionsintersection (in-scope, mixed,[], fully out-of-scope), 404 on unknown catalog, empty-catalog with out-of-scope items seeded (regression test for the scope-escape bug), passthrough of bbox/datetime/ids/limit/sortby/cql2, invalid datetime → 400, scoped self link, and conformance advertising.Verification
pytest tests/(docker, pgstac 0.9.12 + 0.10.0): 3112 passed, 6 xfailedpre-commit run --all-files: isort, ruff, ruff-format, mypy all cleanChecklist
README.mdto reflect any new environment variables, configuration changes, or breaking updates.AI tool usage