Skip to content

Fix duplicated asset events when name_prefix_pattern matches all - #74816

Merged
henry3260 merged 2 commits into
apache:mainfrom
sahilSENPAII:fix-asset-events-prefix-match-all
Nov 5, 2026
Merged

henry3260 merged 2 commits into
apache:mainfrom
sahilSENPAII:fix-asset-events-prefix-match-all

Conversation

@sahilSENPAII

Copy link
Copy Markdown
Contributor

closes: #74814

Problem

GET /api/v2/assets/events?name_prefix_pattern=~ returns each asset event once per asset in the
table. With two assets and one event each, the response contains every event twice and reports
total_entries: 4 instead of 2. An empty name_pattern= takes the same path.

Cause

~ is the documented "match all" alias for name_prefix_pattern and is transformed into an empty
string. get_asset_events joins AssetModel only when a name filter value is truthy, so the join is
skipped for "". The filter itself is still applied, because it skips only None, and it adds a
predicate on asset.name without a join condition. The query becomes a cartesian product of asset
and asset_event. The truthiness check was extended to name_prefix_pattern in #64963.

Fix

Join AssetModel whenever either name filter value is not None, which matches when the filters
themselves are applied.

Testing

  • Added ({"name_prefix_pattern": "~"}, 2) and ({"name_pattern": ""}, 2) to
    TestGetAssetEvents.test_filtering. Both fail without the fix (SQLAlchemy raises its
    cartesian-product SAWarning; with the warning ignored, total_entries is 4 instead of 2) and
    pass with it.
  • test_assets.py: 218 passed.
  • prek passes on both files. generate-openapi-spec and check-tests-in-the-right-folders were
    skipped locally since they need Breeze; the API schema is unchanged.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg

boring-cyborg Bot commented Oct 15, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@Eason09053360 Eason09053360 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch! LGTM :)

The "~" match-all alias for name_prefix_pattern is transformed into an empty
string, so the truthiness check skipped the join to the asset table while the
filter still referenced it, and each event was returned once per asset.
@sahilSENPAII
sahilSENPAII force-pushed the fix-asset-events-prefix-match-all branch from e81ad3c to 7c55d72 Compare November 5, 2026 19:25
@sahilSENPAII

Copy link
Copy Markdown
Contributor Author

Rebased on latest main, CI is green, and it has one approval. @pierrejeambrun @bugraoz93 could one of you take a look when you have time? Thanks.

@henry3260 henry3260 added the backport-to-v3-4-test Backport to v3-4-test label Nov 5, 2026

@henry3260 henry3260 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix!

@henry3260
henry3260 enabled auto-merge (squash) November 5, 2026 21:12
@henry3260
henry3260 merged commit 322c178 into apache:main Nov 5, 2026
72 checks passed
@github-actions github-actions Bot added this to the Airflow 3.4.1 milestone Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.4.1 based on: backport label targeting v3-4-test
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 5, 2026
…hes all (apache#74816)

The "~" match-all alias for name_prefix_pattern is transformed into an empty
string, so the truthiness check skipped the join to the asset table while the
filter still referenced it, and each event was returned once per asset.
(cherry picked from commit 322c178)

Co-authored-by: Sahil Ray <[email protected]>
Co-authored-by: Henry Chen <[email protected]>
shahar1 pushed a commit that referenced this pull request Nov 6, 2026
…hes all (#74816) (#76570)

The "~" match-all alias for name_prefix_pattern is transformed into an empty
string, so the truthiness check skipped the join to the asset table while the
filter still referenced it, and each event was returned once per asset.
(cherry picked from commit 322c178)

Co-authored-by: Sahil Ray <[email protected]>
Co-authored-by: Henry Chen <[email protected]>
vatsrahul1001 pushed a commit that referenced this pull request Nov 9, 2026
…hes all (#74816) (#76570)

The "~" match-all alias for name_prefix_pattern is transformed into an empty
string, so the truthiness check skipped the join to the asset table while the
filter still referenced it, and each event was returned once per asset.
(cherry picked from commit 322c178)

Co-authored-by: Sahil Ray <[email protected]>
Co-authored-by: Henry Chen <[email protected]>
vatsrahul1001 pushed a commit that referenced this pull request Nov 27, 2026
…hes all (#74816) (#76570)

The "~" match-all alias for name_prefix_pattern is transformed into an empty
string, so the truthiness check skipped the join to the asset table while the
filter still referenced it, and each event was returned once per asset.
(cherry picked from commit 322c178)

Co-authored-by: Sahil Ray <[email protected]>
Co-authored-by: Henry Chen <[email protected]>
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 backport-to-v3-4-test Backport to v3-4-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /assets/events returns each event once per asset when name_prefix_pattern is ~

3 participants