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

   Querying logs for a nonexistent task instance returned an internal server 
error instead of a missing resource response, while failed edge jobs omitted 
finish metrics entirely.
   
   In the worker API, requesting logs for a missing task instance dereferenced 
None in the file task handler, raising an AttributeError and returning HTTP 
500. Separately, the job state endpoint checked an invalid comparison list that 
prevented the failed state from matching, so finish metrics were never emitted 
on job failure.
   
   This change returns a 404 Not Found error when the task instance cannot be 
found and corrects the state list so finish metrics emit for both successful 
and failed tasks.
   
   # Testing Done
   
   Reproduction before fix:
   ```bash
   uv run --project providers/edge3 pytest -k "test_logfile_path_missing_ti or 
test_state_failed"
   ```
   
   Pre-fix output:
   ```text
   FAILED test_logs.py test_logfile_path_missing_ti_returns_404 - 
AttributeError: 'NoneType' object has no attribute 'get_dagrun'
   FAILED test_jobs.py test_state_failed - AssertionError: expected call not 
found
   ```
   
   Verification after fix:
   ```bash
   uv run --project providers/edge3 pytest 
providers/edge3/tests/unit/edge3/worker_api/routes/test_logs.py 
providers/edge3/tests/unit/edge3/worker_api/routes/test_jobs.py -k 
"test_logfile_path or test_state_failed"
   ```
   
   Post-fix output:
   ```text
   ================== 3 passed, 9 deselected, 1 warning in 4.03s 
==================
   ```
   
   <details>
   <summary>Raw logs</summary>
   
   ```text
   test_logs.py test_logfile_path PASSED [ 33%]
   test_logs.py test_logfile_path_missing_ti_returns_404 PASSED [ 66%]
   test_jobs.py test_state_failed PASSED [100%]
   ```
   
   </details>
   


-- 
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