Fix run_id_pattern pipe OR operator dropping single-term edge cases#65190
Draft
coleheflin wants to merge 1 commit intoapache:mainfrom
Draft
Fix run_id_pattern pipe OR operator dropping single-term edge cases#65190coleheflin wants to merge 1 commit intoapache:mainfrom
coleheflin wants to merge 1 commit intoapache:mainfrom
Conversation
29e8fdf to
a134e7e
Compare
When a pattern like "term|" or "|term" was passed, the OR-split guard
`if len(search_terms) > 1` evaluated False for the single remaining
term, falling through to `ilike("%term|%")` / `ilike("%|term%")` which
matched nothing. Changing the guard to `if search_terms:` ensures a
single valid term is used correctly.
closes: apache#65129
a134e7e to
a9e0f92
Compare
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.
When
run_id_pattern(or any other_SearchParam-based filter) received a trailing or leading pipe — e.g.term|or|term— the guardif len(search_terms) > 1evaluatedFalsefor the single remaining term and fell through to the raw fallback:Neither pattern matches any realistic value, so the endpoint silently returned an empty list.
Changes
airflow-core/src/airflow/api_fastapi/common/parameters.py— one-character fix:if len(search_terms) > 1:→if search_terms:. SQLAlchemy'sor_()with a single argument compiles to just that condition, so no SQL correctness risk. Applies to every endpoint usingsearch_param_factory.airflow-core/tests/unit/api_fastapi/common/test_parameters.py— two unit regression tests for trailing/leading pipe edge cases.airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py— three integration tests: one proving the basic OR case (a|breturns both runs, directly demonstrating the reported behaviour works), and two regression tests for the trailing/leading pipe edge cases.Test results
closes: #65129
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Sonnet 4.6 following the guidelines