Under which category would you file this issue?
Airflow Core
Apache Airflow version
main
What happened and how to reproduce it?
Issue Description
In the airflow-core package, specifically in airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py inside the ti_run route, a domain-layer exception is currently leaking.
If a DagRun is not found during the ti_run endpoint execution, the code raises a ValueError directly:
raise ValueError(f"DagRun with dag_id={ti.dag_id} and run_id={ti.run_id} not found.")
Because this ValueError is raised inside the route and not caught, it results in an unhandled HTTP 500 Internal Server Error being returned to the client.
Steps to reproduce:
Call the PATCH /execution/task-instances/{task_instance_id}/run endpoint with a valid task_instance_id where the corresponding DagRun does not exist in the database.
What you think should happen instead?
Per the Airflow coding standards, domain-layer exceptions should be translated to an HTTPException at FastAPI route boundaries to avoid leaking internals.
This should be replaced with:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=...)
Operating System
Not Applicable
Deployment
None
Apache Airflow Provider(s)
No response
Versions of Apache Airflow Providers
Not Applicable
Official Helm Chart version
Not Applicable
Kubernetes Version
Not Applicable
Helm Chart configuration
Not Applicable
Docker Image customizations
Not Applicable
Anything else?
already have a fix for this and will be opening a PR shortly!
Are you willing to submit PR?
Code of Conduct
Under which category would you file this issue?
Airflow Core
Apache Airflow version
main
What happened and how to reproduce it?
Issue Description
In the
airflow-corepackage, specifically inairflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.pyinside theti_runroute, a domain-layer exception is currently leaking.If a
DagRunis not found during theti_runendpoint execution, the code raises aValueErrordirectly:raise ValueError(f"DagRun with dag_id={ti.dag_id} and run_id={ti.run_id} not found.")Because this
ValueErroris raised inside the route and not caught, it results in an unhandled HTTP 500 Internal Server Error being returned to the client.Steps to reproduce:
Call the
PATCH /execution/task-instances/{task_instance_id}/runendpoint with a validtask_instance_idwhere the correspondingDagRundoes not exist in the database.What you think should happen instead?
Per the Airflow coding standards, domain-layer exceptions should be translated to an
HTTPExceptionat FastAPI route boundaries to avoid leaking internals.This should be replaced with:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=...)Operating System
Not Applicable
Deployment
None
Apache Airflow Provider(s)
No response
Versions of Apache Airflow Providers
Not Applicable
Official Helm Chart version
Not Applicable
Kubernetes Version
Not Applicable
Helm Chart configuration
Not Applicable
Docker Image customizations
Not Applicable
Anything else?
already have a fix for this and will be opening a PR shortly!
Are you willing to submit PR?
Code of Conduct