Lorenzo-N opened a new issue #13843: URL: https://github.com/apache/airflow/issues/13843
**Apache Airflow version**: 2.0.0 **Kubernetes version (if you are using kubernetes)**: NA **Environment**: Docker - **OS**: CentOS Linux 7 (Core) - **Python version**: 3.6.8 **What happened**: Every time I call get_log api (https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_log) to get logs for a specific task instance that is not in the dag now, I get the TaskNotFound exception. ```Traceback (most recent call last): File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib64/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/local/lib/python3.6/site-packages/connexion/decorators/decorator.py", line 48, in wrapper response = function(request) File "/usr/local/lib/python3.6/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper response = function(request) File "/usr/local/lib/python3.6/site-packages/connexion/decorators/validation.py", line 384, in wrapper return function(request) File "/usr/local/lib/python3.6/site-packages/connexion/decorators/response.py", line 103, in wrapper response = function(request) File "/usr/local/lib/python3.6/site-packages/connexion/decorators/parameter.py", line 121, in wrapper return function(**kwargs) File "/usr/local/lib/python3.6/site-packages/airflow/api_connexion/security.py", line 47, in decorated return func(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/airflow/utils/session.py", line 65, in wrapper return func(*args, session=session, **kwargs) File "/usr/local/lib/python3.6/site-packages/airflow/api_connexion/endpoints/log_endpoint.py", line 74, in get_log ti.task = dag.get_task(ti.task_id) File "/usr/local/lib/python3.6/site-packages/airflow/models/dag.py", line 1527, in get_task raise TaskNotFound(f"Task {task_id} not found") airflow.exceptions.TaskNotFound: Task 0-1769e47c-5933-42f9-ac59-b59c7de13382 not found ``` **What you expected to happen**: Even if the task is not in the dag now I expect to get its log in a past run. **How to reproduce it**: Create a dag with a few tasks and run it. Then remove a task from the dag and try to get the log of the removed task in the past run using the api. **Anything else we need to know**: The problem is that in https://github.com/apache/airflow/blob/master/airflow/api_connexion/endpoints/log_endpoint.py at line 73 there is a call to get the task from current dag without catching the TaskNotFound exception. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
