1fanwang opened a new pull request, #66775:
URL: https://github.com/apache/airflow/pull/66775

   Closes #42790.
   
   `QueryOwnersFilter` (in 
`airflow-core/src/airflow/api_fastapi/common/parameters.py`) filters 
`DagModel.owners` with `ilike(f\"%{owner}%\")`. Because `DagModel.owners` is 
the comma-joined list of all task owners for a DAG, filtering for `Admin` 
returns DAGs whose owner is `NotAnAdmin` — `%Admin%` substring-matches anywhere 
in the joined string.
   
   The fix normalises the column to `,owner1,owner2,...,owner_n,` with 
`func.replace` + `func.concat`, then ILIKEs against `'%,<owner>,%'`. Single 
ILIKE per term, cross-dialect (SQLite/Postgres/MySQL), index-friendly enough 
that the existing pagination plan doesn't regress.
   
   Affects `GET /dags`, `GET /ui/dags`, and any endpoint sharing 
`QueryOwnersFilter`.
   
   ## Tests
   
   - 
`airflow-core/tests/unit/api_fastapi/common/test_parameters.py::TestOwnersFilter`
 — compiles the statements and asserts the rendered SQL contains 
`'%,airflow,%'` rather than `'%airflow%'`.
   - 
`airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py::TestGetDags`
 — parametrized integration cases including the canonical collision (filter 
`owner` against stored `test_owner,another_test_owner` returns 0 results; 
filter `another_test_owner` returns the DAG; multi-value OR works).
   
   The new tests fail on `main` (wrong row counts under the substring 
predicate) and pass with this PR.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to