Skip to content

Pass task/asset scopes to serialize methods instead of ti_id/asset_ref#68274

Merged
amoghrajesh merged 5 commits into
apache:mainfrom
astronomer:aip-103-serialize-signature-change
Jun 10, 2026
Merged

Pass task/asset scopes to serialize methods instead of ti_id/asset_ref#68274
amoghrajesh merged 5 commits into
apache:mainfrom
astronomer:aip-103-serialize-signature-change

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

What

Related to #66859

serialize_task_store_to_ref and serialize_asset_store_to_ref on BaseStoreBackend previously received ti_id: str (a UUID) and asset_ref: str respectively. A new ti_id is issued on every task retry, so any object storage path derived from it would be different per retry, that means that a job ID written by try 1 would be unreachable by try 2 when a backend tries to reconnect to an existing external job (the primary use case for a custom backend, e.g. ResumableJobMixin).

Current behaviour

serialize_task_store_to_ref receives a UUID (ti_id) that changes each retry. A custom backend deriving its storage path from ti_id produces a different path per retry, orphaning values written by previous tries. Similarly, serialize_asset_store_to_ref receives a plain string (asset_ref) that loses the distinction between name and URI.

Proposed change

Both methods now receive a scope object - TaskScope (dag_id, run_id, task_id, map_index) for the task variant and AssetScope (name, uri) for the asset variant.

The scope is stable across retries for the same logical task instance, so a custom backend can derive a deterministic, retry-stable path. The AssetScope change also lets backends correctly distinguish name vs URI when constructing paths.

context.py call sites updated to pass self._scope (task) and AssetScope(name=..., uri=...) (asset) instead of the previous string values.

Testing

Check in the diff, InMemoryStoreBackend is an implementation

  • Updated InMemoryStoreBackend in test_context.py to implement the new signatures, constructing a mem://dag/run/task/map_index/key path from the full TaskScope matching the structure a real object storage backend would use.

  • Read the 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) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

Comment thread airflow-core/docs/administration-and-deployment/task-and-asset-store.rst Outdated
Comment thread task-sdk/src/airflow/sdk/execution_time/context.py
Comment thread airflow-core/docs/administration-and-deployment/task-and-asset-store.rst Outdated
@amoghrajesh

Copy link
Copy Markdown
Contributor Author

Failures are unrelated:

ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_mongo_conn_id - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_get_conn - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_srv - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_invalid_conn_type - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_invalid_conn_type_srv - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_invalid_srv_with_port - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_insert_one - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_insert_many - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_update_one - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_update_one_with_upsert - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_update_many - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_update_many_with_upsert - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_replace_one - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_replace_one_with_filter - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_replace_one_with_upsert - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_replace_many - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_replace_many_with_upsert - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_create_uri_with_all_creds - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_create_uri_no_creds - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_create_uri_srv_true - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_delete_one - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_delete_many - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_find_one - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_find_many - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_find_many_with_projection - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_aggregate - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_distinct - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_distinct_with_filter - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_create_standard_collection - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_return_if_exists_true_returns_existing - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::TestMongoHook::test_return_if_exists_false_raises - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::test_context_manager - Failed: Timeout >60.0s
ERROR providers/mongo/tests/unit/mongo/hooks/test_mongo.py::test_allow_insecure_and_ssl_enabled - Failed: Timeout >60.0s

@amoghrajesh amoghrajesh merged commit b311e6f into apache:main Jun 10, 2026
98 of 100 checks passed
@amoghrajesh amoghrajesh deleted the aip-103-serialize-signature-change branch June 10, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants