False Positive: "Statement has no effect" on Airflow task chaining with >> operator
還沒有人認領這個 Issue。
評估
研究方向
首先,使用 issue 中的最小 Apache Airflow Python 範例重現該警示。閱讀與「Statement has no effect」警示相關的 CodeQL 查詢和 Python 建模,然後判斷如何分析多載的 >> 運算式。完成的標準是:Airflow 工作串接陳述式不再被回報,同時真正沒有作用的陳述式仍然可以被偵測到。
由索引模型根據 Issue 內容生成。
描述
Description of the false positive
The CodeQL analysis is reporting a "Statement has no effect" false positive when using Apache Airflow's operator chaining syntax with >>. This is a valid and idiomatic way to declare task dependencies in Airflow DAGs, and these statements have clear side effects within the context of Airflow’s task graph construction.
Code samples or links to source code
The following is a minimal reproducible example using Apache Airflow:
from airflow import DAG
from airflow.operators.empty import EmptyOperator
from datetime import datetime
with DAG("example_dag", start_date=datetime(2025, 6, 5), schedule_interval=None) as dag:
task_1 = EmptyOperator(task_id="task_1")
task_2 = EmptyOperator(task_id="task_2")
task_3 = EmptyOperator(task_id="task_3")
task_4 = EmptyOperator(task_id="task_4")
task_1 >> task_2 # CodeQL incorrectly flags this
task_2 >> [task_3, task_4] # CodeQL incorrectly flags this too
These lines are not no-op statements; they define execution order between tasks (task_1 precedes task_2, etc.). Removing them would break DAG functionality.
URL to the alert on GitHub code scanning (optional)
Code is proprietary.
Suggested solution
If possible, please provide a way to configure CodeQL to ignore >> operator overload on Airflow operator objects, which have intentional and important side effects.. Please note that this operator works only in DAG context manager (with DAG(...) as dag:).
If that's not feasible, then I would greatly appreciate help setting up custom CodeQL rule to ignore this false positive.
- 主要語言
- CodeQL
- 星號
- 10.1k
- 分支
- 2.1k
- 平均合併
- 2 天 17 小時
- 30 天內合併 PR
- 145
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/codeql 的其他 Issue
-
agentic-workflows
難度 2/5 1-3 小時 新手友好度 70/100
-
false-positive javascript
難度 2/5 1-3 小時 新手友好度 84/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
false-positive
難度 2/5 1-3 小時 新手友好度 70/100
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
stephrobert/dsoxlab#238 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 75/100
sublimehq/package_control#1780 ·
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
typelevel/sbt-typelevel#929 ·
-
難度 2/5 1-3 小時 新手友好度 65/100
antfu-collective/icones#398 ·