fix: propagate rendered_map_index through the reschedule state path#68829
Open
kalluripradeep wants to merge 2 commits into
Open
fix: propagate rendered_map_index through the reschedule state path#68829kalluripradeep wants to merge 2 commits into
kalluripradeep wants to merge 2 commits into
Conversation
2 tasks
When a mapped sensor raises AirflowRescheduleException the rendered_map_index
(the human-readable label derived from map_index_template) was silently dropped,
leaving the DB column NULL on every UP_FOR_RESCHEDULE transition. All other
intermediate-state payloads (deferred, awaiting-input, retry, terminal) already
carry rendered_map_index; this fix closes the gap for the reschedule path.
Changes:
- Add `rendered_map_index` field to `TIRescheduleStatePayload` (server + client)
- Pass `ti.rendered_map_index` when constructing `RescheduleTask` in task_runner
- Store it in `_rendered_map_index` in both supervisor RescheduleTask handlers
- Write it to the DB in the `/task-instances/{id}/state` route handler
- Regenerate schema.json snapshot
- Add Cadwyn version migration (v2026-06-30) for backward compatibility
- Add regression test
Closes apache#67521
MyPy cannot infer the return type of `anyio.from_thread.run(request.form)` without an explicit annotation. Add `FormData` to a TYPE_CHECKING block (satisfying ruff TC002) and annotate both call sites with `# type: ignore[arg-type]` to silence the incompatible-argument error that exists on main.
a210c23 to
3dc8a05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the problem?
TIRescheduleStatePayloadwas the only intermediate-state payload missingrendered_map_index. As a result, when a mapped sensor setscontext["map_index_template"]inside itspoke()body and then raisesAirflowRescheduleExceptionto reschedule, therendered_map_indexvalue is never persisted to the database. The UI displays the raw integermap_index(e.g.0,1) on everyup_for_reschedulerow instead of the human-readable rendered label.The final successful poke does show the rendered label (because the success path already serialises
rendered_map_indexviaTaskState), so the column appears intermittently.Fixes #67521
Root cause
The full data path for a reschedule is:
All other intermediate states (
TIDeferredStatePayload,TIAwaitingInputStatePayload,TIRetryStatePayload,TITerminalStatePayload,TISuccessStatePayload) already carryrendered_map_index. The reschedule path was the only one left out.Note:
_render_map_index()is called in theexcept Exception:block (line ~1576 oftask_runner.py) before re-raisingAirflowRescheduleException, soti.rendered_map_indexis correctly populated by the time we buildRescheduleTask. We only need to pass it through.Changes
airflow-core/…/datamodels/taskinstance.pyrendered_map_index: str | None = NonetoTIRescheduleStatePayload(server-side model)task-sdk/…/api/datamodels/_generated.pytask-sdk/…/execution_time/task_runner.pyrendered_map_index=ti.rendered_map_indexwhen constructingRescheduleTasktask-sdk/…/execution_time/supervisor.pyself._rendered_map_index = msg.rendered_map_indexin bothRescheduleTaskhandler branchesairflow-core/…/routes/task_instances.py_rendered_map_index=ti_patch_payload.rendered_map_indexin theUP_FOR_RESCHEDULEqueryairflow-core/…/versions/v2026_06_30.pyAddRenderedMapIndexToReschedulePayloadairflow-core/…/versions/__init__.py2026-06-30version bundletask-sdk/tests/…/test_task_runner.pytest_run_reschedule_includes_rendered_map_indexTesting
New regression test verifies that when a sensor sets
map_index_templateand rescheduled, theRescheduleTaskmessage carriesrendered_map_index: