Revanth14 opened a new pull request, #67822:
URL: https://github.com/apache/airflow/pull/67822

   
   ---
   Fixes: #67813
   
   The scheduler orphaned-task adoption path loaded task instances with a 
narrow `load_only(...)` set and then called `repr(ti)` while building the reset 
log message. `TaskInstance.__repr__` reads `map_index` and `state`, so detached
   instances with deferred columns could raise `DetachedInstanceError` and 
crash the scheduler on restart.
   
   This updates the scheduler query to load the fields needed by `repr(ti)` and 
makes `TaskInstance.__repr__` defensive for detached/deleted ORM instances used 
in logging.
   
   Tests:
   - `uv run --project airflow-core pytest 
airflow-core/tests/unit/models/test_taskinstance.py::test_task_instance_repr_does_not_raise_for_deferred_columns
 
airflow-core/tests/unit/jobs/test_scheduler_job.py::TestSchedulerJob::test_adopt_or_reset_orphaned_tasks_loads_state_for_reset_logging
 -q`
     - 2 passed
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [ X] Yes (please specify the tool below)
   
   <!--
   Generated-by: [Opus 4.8] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   


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