Skip to content

Add exact-match uri filter to GET /assets endpoint#69489

Open
seanmuth wants to merge 1 commit into
apache:mainfrom
seanmuth:restore-asset-uri-exact-lookup
Open

Add exact-match uri filter to GET /assets endpoint#69489
seanmuth wants to merge 1 commit into
apache:mainfrom
seanmuth:restore-asset-uri-exact-lookup

Conversation

@seanmuth

@seanmuth seanmuth commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

Adds a uri query parameter to GET /api/v2/assets that matches an asset by its exact URI, backed by a new single-column index on asset.uri.

Why

Today, resolving a single asset when you already know its full URI (for example, discovering an asset_id before posting to /assets/{asset_id}/events for cross-deployment dependencies) requires uri_pattern. That parameter compiles to ILIKE '%...%', which cannot use a B-tree index and degrades to a full table scan on large asset tables — the API docs themselves warn about this.

The Airflow 2 REST API offered a fast exact lookup via GET /datasets/{uri} (later GET /assets/{uri}), but it was not carried forward when the endpoint migrated to FastAPI under AIP-84 — the single-resource route became GET /assets/{asset_id} (integer PK only). This PR restores the exact-URI lookup as a query parameter.

Passing the URI as a query parameter rather than a path segment also avoids the URI-encoding problems path parameters have with the /, :, and %2F characters that asset URIs contain.

What changed

  • New uri exact-match filter on GET /assets (equality comparison via the existing filter_param_factory).
  • New non-unique index idx_asset_uri on asset.uri (the existing unique index leads with name and cannot serve uri-only lookups), with an Alembic migration.
  • Regenerated OpenAPI spec + UI client, updated REVISION_HEADS_MAP and migration ref doc.
  • Tests: exact-match hits plus negative cases confirming a substring does not match (unlike uri_pattern).

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8, 1M context)

Generated-by: Claude Code (Opus 4.8, 1M context) following the guidelines


Drafted-by: Claude Code (Opus 4.8, 1M context) (no human review before posting)

Resolving a single asset by its full URI currently requires uri_pattern,
which compiles to ILIKE '%...%' and cannot use a database index, so it
degrades to a full table scan on large asset tables. This is the fast,
index-backed exact-URI lookup that the Airflow 2 REST API exposed via
GET /datasets/{uri} but that was not carried forward when the endpoint
moved to FastAPI under AIP-84.

The uri query parameter matches an asset by its exact URI using an
equality comparison, backed by a new single-column index on asset.uri
(the existing unique index leads with name and cannot serve uri-only
lookups). Passing it as a query parameter rather than a path segment
avoids the URI-encoding problems that path parameters have with the
'/' and ':' characters in asset URIs.
@seanmuth seanmuth force-pushed the restore-asset-uri-exact-lookup branch from d549e9b to 5416302 Compare July 6, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:db-migrations PRs with DB migration area:UI Related to UI/UX. For Frontend Developers. kind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant