josix opened a new pull request, #73618:
URL: https://github.com/apache/airflow/pull/73618
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull
request.
Write a good git commit message following this guide:
https://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the
documentation.
For user-facing UI changes, please attach before/after screenshots (or a
short
screen recording) so reviewers can assess the visual impact.
Feel free to ping (in general) for the review if you do not see reaction for
a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we
sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
TypeScript task handlers previously had no access to the per-task-instance
state store that Python tasks expose through `context["task_state_store"]`. As
a result, a retried TypeScript task could not reconnect to an external job
submitted by an earlier attempt.
The supervisor and generated wire types already support the four state-store
messages. This change exposes that functionality through the TypeScript client,
adds coverage to the example bundle and `ts_sdk` e2e mode, and updates the
compatibility matrix to mark `task-state-store` as supported.
New `TaskClient` methods, named after the wire messages like the rest of the
client:
- `getTaskStateStore<T>(key)` returns the value, or `null` when the key is
missing.
- `setTaskStateStore({ key, value, retentionMs? })` stores a value.
`NEVER_EXPIRE` stores it with no expiry.
- `deleteTaskStateStore(key)` removes one key and resolves when the key does
not exist.
- `clearTaskStateStore()` removes every key for the current task instance.
<!--
Notes for reviewers:
- **Task instance id.** The Execution API confines the store to the caller's
own task instance, so the id is bound when the coordinator client is built.
`TaskContext` is unchanged, and handlers cannot address another task instance's
store.
- **Absence handling.** The shared not-found code set is replaced by a
per-operation policy, which resolves the TODO in `coordinator/client.ts`.
Variable, XCom and Connection lookups behave exactly as before. A state-store
read treats only `TASK_STORE_NOT_FOUND` as absent, because the task SDK API
client already maps every 404 on that route to that code.
- **Retention.** `expires_at` is resolved on the runtime, as Python does.
Omitting `retentionMs` reads `AIRFLOW__STATE_STORE__DEFAULT_RETENTION_DAYS`
from the worker environment and falls back to 30 days, Airflow's default, when
it is unset. `0` means never expire, matching Python. On main the coordinator
does not forward this setting yet. #73420 adds that for every subprocess
runtime, and this client picks it up without further changes once that lands.
- **Guards before sending.** A non-string or empty key, a `null` or
non-finite value, and an expiry past year 9999 are rejected on the client. Each
of these otherwise reaches the supervisor as a frame it cannot decode, and the
supervisor drops it without replying, so the task would hang, or it comes back
as a misleading 422.
- **Not in scope.** The worker-side `[workers] state_store_backend` is not
used, since a Node process cannot load a Python backend class. This matches
#73420 and #73464, and the TypeScript guide documents it.
Related: #73420 (Go SDK), #73464 (Java SDK).
-->
---
##### 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 (Claude Code Fable 5.1)
<!--
Generated-by: [Tool Name] following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information. Note: commit author/co-author name and email in commits
become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment:
`{pr_number}.significant.rst`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
You can add this file in a follow-up commit after the PR is created so you
know the PR number.
--
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]