You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "coleheflin (via GitHub)" <gi...@apache.org> on 2026/04/14 03:54:54 UTC

[PR] Fix run_id_pattern pipe OR operator dropping single-term edge cases [airflow]

coleheflin opened a new pull request, #65190:
URL: https://github.com/apache/airflow/pull/65190

   When `run_id_pattern` (and other `_SearchParam`-based filters) contained a trailing or leading pipe character — e.g. `term|` or `|term` — the existing guard `if len(search_terms) > 1` evaluated to `False` for the single remaining term and fell through to the raw fallback:
   
   ```python
   select.where(self.attribute.ilike(f"%{self.value}%"))
   # → LIKE '%term|%'  or  LIKE '%|term%'
   ```
   
   Neither pattern matches any realistic run ID, so the endpoint silently returned an empty list instead of the expected results.
   
   ## Changes
   
   **`airflow-core/src/airflow/api_fastapi/common/parameters.py`**
   
   One-character fix — `if len(search_terms) > 1:` → `if search_terms:`. SQLAlchemy's `or_()` with a single argument compiles cleanly to just that condition (no spurious `OR` keyword), so no SQL correctness risk. The fix applies to every endpoint that uses `_SearchParam` via `search_param_factory` (`run_id_pattern`, `dag_id_pattern`, `task_id_pattern`, etc.).
   
   **`airflow-core/tests/unit/api_fastapi/common/test_parameters.py`**
   
   Three new unit tests on `_SearchParam.to_orm`:
   - `test_to_orm_multiple_values_or_no_spaces` — pipe without surrounding spaces (`"a|b"`)
   - `test_to_orm_pipe_with_trailing_pipe` — single term with trailing pipe (`"term|"`) — **regression test**, fails without the fix
   - `test_to_orm_pipe_with_leading_pipe` — single term with leading pipe (`"|term"`) — **regression test**, fails without the fix
   
   **`airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py`**
   
   Six new parametrize cases on `TestGetDagRuns::test_filters`:
   - OR without spaces: `dag_run_1|dag_run_2` → returns both runs
   - OR with spaces: `dag_run_1 | dag_run_2` → returns both runs
   - OR scoped to a specific DAG
   - OR with one valid + one non-existent term → returns only the matching run
   - Trailing pipe `dag_run_1|` → returns `dag_run_1` — **regression test**, fails without the fix
   - Leading pipe `|dag_run_1` → returns `dag_run_1` — **regression test**, fails without the fix
   
   ## Test results
   
   ```
   # With fix applied
   73 passed (5 unit + 68 integration)
   
   # With fix reverted — regression tests correctly fail
   FAILED test_filters[~-query_params32-...] - AssertionError: [] != ['dag_run_1']
   FAILED test_filters[~-query_params33-...] - AssertionError: [] != ['dag_run_1']
   2 failed, 71 passed
   ```
   
   closes: #65129
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Sonnet 4.6 (claude-sonnet-4-6)
   
   Generated-by: Claude Sonnet 4.6 following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix run_id_pattern pipe OR operator dropping single-term edge cases [airflow]

Posted by "coleheflin (via GitHub)" <gi...@apache.org>.
coleheflin commented on PR #65190:
URL: https://github.com/apache/airflow/pull/65190#issuecomment-4271306705

   The two CI failures are pre-existing on `main` and unrelated to this change:
   
   - **ruff** `PT006` in `test_dagbag.py:92` — file not touched by this PR, violation already present on `main`
   - **yamllint** on `config.yml` — file not touched by this PR, no diff between this branch and `main`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix run_id_pattern pipe OR operator dropping single-term edge cases [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun merged PR #65190:
URL: https://github.com/apache/airflow/pull/65190


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix run_id_pattern pipe OR operator dropping single-term edge cases [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #65190:
URL: https://github.com/apache/airflow/pull/65190#issuecomment-4283576466

   ### Backport successfully created: v3-2-test
   
   Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
   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](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
   
   <table>
           <tr>
           <th>Status</th>
           <th>Branch</th>
           <th>Result</th>
       </tr>
       <tr>
           <td>✅</td>
           <td>v3-2-test</td>
           <td><a href="https://github.com/apache/airflow/pull/65565"><img src="https://img.shields.io/badge/PR-65565-blue" alt="PR Link"></a></td>
       </tr>
   </table>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org