You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jroachgolf84 (via GitHub)" <gi...@apache.org> on 2026/06/23 12:52:54 UTC

[PR] Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

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

   ## Description
   
   When attempting to use the Asset State Store from within a `BaseEventTrigger`, the following exception was thrown:
   
   ```
   Traceback (most recent call last):
     File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/supervisor.py", line 890, in handle_requests
       msg = self.decoder.validate_python(self._deserialize_request(request.body))
     File "/usr/python/lib/python3.10/site-packages/pydantic/type_adapter.py", line 441, in validate_python
       return self.validator.validate_python(
   
   pydantic_core._pydantic_core.ValidationError: 1 validation error for tagged-union[
     TriggerStateChanges, GetConnection, DeleteVariable, GetVariable, GetVariableKeys,
     PutVariable, DeleteXCom, GetXCom, SetXCom, GetTICount, GetTaskStates, GetDagRunState,
     GetDRCount, GetPreviousTI, GetHITLDetailResponse, UpdateHITLDetail, MaskSecret
   ]
   
     Input tag 'GetAssetStateStoreByName' found using 'type' does not match any of the expected tags:
     'TriggerStateChanges', 'GetConnection', 'DeleteVariable', 'GetVariable', 'GetVariableKeys',
     'PutVariable', 'DeleteXCom', 'GetXCom', 'SetXCom', 'GetTICount', 'GetTaskStates',
     'GetDagRunState', 'GetDRCount', 'GetPreviousTI', 'GetHITLDetailResponse', 'UpdateHITLDetail',
     'MaskSecret'
   
     [type=union_tag_invalid, input_value={'name': 'generic_asset', ... 'type': 'GetAssetStateStoreByName'}, input_type=dict]
   ```
   
   This was called out as something that needed to be addressed by @vikramkoka in #67839. This PR addresses this error by adding a pathway for each of the 8 operations that the Asset State Store can perform.
   
   related: #67839
   
   ## Testing
   
   Changes were tested using both unit-tests, as well as E2E. Unit-tests can be run using the below commands:
   
   ```bash
   breeze testing core-tests airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_asset_state_store.py
   
   breeze testing core-tests airflow-core/tests/unit/jobs/test_triggerer_job.py
   ```
   
   To test this E2E, a custom `BaseEventTrigger` was written to test `get`, `set`, `delete`, and `clear` operations. The DAG that uses this Trigger executes successfully E2E, and the Triggered contains all of the expected logging statements.
   
   ```python
   from airflow.triggers.base import BaseEventTrigger, TriggerEvent
   from collections.abc import AsyncIterator
   from typing import Any
   
   import asyncio
   import logging
   import random
   
   
   class GenericEventTrigger(BaseEventTrigger):
       def __init__(
           self,
           random_number,
           waiter_delay,
           asset_name,
           **kwargs
       ):
           super().__init__(**kwargs)
   
           self.random_number = random_number
           self.waiter_delay = waiter_delay
           self.asset_name = asset_name
   
       def serialize(self) -> tuple[str, dict[str, Any]]:
           """Serialize the Trigger, including the func, params, and waiter_delay."""
           return (
               self.__class__.__module__ + "." + self.__class__.__qualname__,
               {
                   "random_number": self.random_number,
                   "waiter_delay": self.waiter_delay,
                   "asset_name": self.asset_name,
               },
           )
   
       async def run(self) -> AsyncIterator[TriggerEvent]:
           """Logic that fires a TriggerEvent."""
           asset_state_store = self.asset_state_store
           logging.info(f"asset_state_store: {asset_state_store}")
   
           # Clearing state store before starting (in case there is anything there)
           asset_state_store.clear()
           logging.info(f"cleared asset_state_store")
   
           while True:
               # Get the previous number
               last_result = asset_state_store.get("result", -1)
               logging.info(f"last_result: {last_result}")
   
               # Create a new number
               result = random.randint(0, 5)
               asset_state_store.set("result", result)
               logging.info(f"result: {result}")
   
               if result == self.random_number:
                   logging.info("yield'ing TriggerEvent")
                   yield TriggerEvent({"status": "success", "result": result})
   
                   # Clear the state_store
                   asset_state_store.delete(key="result")  # Should this work?
                   logging.info(f"deleted 'result' key for asset_state_store")
                   break
   
               logging.info(f"Sleeping for {self.waiter_delay} seconds")
               await asyncio.sleep(self.waiter_delay)
   
   ```
   
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3461391497


##########
task-sdk/src/airflow/sdk/execution_time/request_handlers.py:
##########


Review Comment:
   Added tests in next commit.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3464559601


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/asset_state_store.py:
##########
@@ -51,8 +51,8 @@
 _TIWriterFields = tuple[str, str, str, int]
 
 
-def _fetch_ti_writer_fields(token: TIToken, session: SessionDep) -> _TIWriterFields:
-    """Return (dag_id, run_id, task_id, map_index) for the TI identified by the token."""

Review Comment:
   Checking this more carefully, the `None` return value treats two things the same way: 
   
   - a watcher trigger (which intentionally carries the null UUID sentinel) and
   - any non-null token whose TI row happens to be missing. In practice the second case probably cannot happen today, but I would rather be safe here. An explicit `token.id == NULL_UUID` check for the watcher branch keeps the 404 intact for everything else, and makes it obvious from reading the code why we are skipping the TI lookup rather than inferring it from a missing row. Feels like a small change for a meaningful safety net.



##########
task-sdk/tests/task_sdk/execution_time/test_request_handlers.py:
##########


Review Comment:
   Most tests in this file follow same kind of pattern, you could just have a single test with parameterise instead, something like:
   
   ```python
   @pytest.mark.parametrize("msg,method,call_kwargs,expected_result", [
       (
           SetAssetStateStoreByName(name="asset_a", key="k", value="v"),
           "set", {"key": "k", "value": "v", "name": "asset_a"}, None,
       ),
       ...
   ])
   def test_xyz(client, msg, method, call_kwargs, expected_result):
       handle = HANDLER_MAP[type(msg)]
       result, dump_opts = handle(client, msg)
       getattr(client.asset_state_store, method).assert_called_once_with(**call_kwargs)
       assert result is expected_result
       assert dump_opts == {}
   ```



##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -834,6 +845,94 @@ async def test_create_triggers_asset_state_store_accessor_reads_and_writes(
     await runner.cleanup_finished_triggers()
 
 
+class TestTriggerSupervisorAssetStateStore:
+    """Supervisor side of the asset-state-store round trip.
+
+    The accessor-only test above asserts the messages a watcher trigger emits, but never
+    exercises ``TriggerRunnerSupervisor._handle_request``. These drive the supervisor
+    directly so a broken (or missing) branch can't pass silently.
+    """
+
+    @pytest.fixture
+    def supervisor(self, jobless_supervisor, mocker):
+        jobless_supervisor.client = mocker.MagicMock(spec=Client)
+        mocker.patch.object(TriggerRunnerSupervisor, "send_msg")
+        return jobless_supervisor
+
+    @staticmethod
+    def _handle(supervisor, msg):
+        supervisor._handle_request(msg, log=MagicMock(spec=FilteringBoundLogger), req_id=7)
+
+    def test_get_by_name_wraps_response_and_replies(self, supervisor):
+        supervisor.client.asset_state_store.get.return_value = AssetStateStoreResponse(value="2026-01-01")
+
+        self._handle(supervisor, GetAssetStateStoreByName(name="asset_a", key="watermark"))
+
+        supervisor.client.asset_state_store.get.assert_called_once_with(key="watermark", name="asset_a")
+        supervisor.send_msg.assert_called_once_with(
+            AssetStateStoreResult(value="2026-01-01"), request_id=7, error=None
+        )
+
+    def test_get_by_uri_wraps_response_and_replies(self, supervisor):
+        supervisor.client.asset_state_store.get.return_value = AssetStateStoreResponse(value="2026-01-01")
+
+        self._handle(supervisor, GetAssetStateStoreByUri(uri="s3://bucket/a", key="watermark"))
+
+        supervisor.client.asset_state_store.get.assert_called_once_with(key="watermark", uri="s3://bucket/a")
+        supervisor.send_msg.assert_called_once_with(
+            AssetStateStoreResult(value="2026-01-01"), request_id=7, error=None
+        )
+
+    def test_get_passes_through_not_found_error(self, supervisor):
+        err = ErrorResponse(error=ErrorType.ASSET_STORE_NOT_FOUND, detail={"key": "watermark"})
+        supervisor.client.asset_state_store.get.return_value = err
+
+        self._handle(supervisor, GetAssetStateStoreByName(name="asset_a", key="watermark"))
+
+        supervisor.send_msg.assert_called_once_with(err, request_id=7, error=None)
+
+    def test_set_by_name(self, supervisor):
+        self._handle(
+            supervisor, SetAssetStateStoreByName(name="asset_a", key="watermark", value="2026-01-01")
+        )
+
+        supervisor.client.asset_state_store.set.assert_called_once_with(
+            key="watermark", value="2026-01-01", name="asset_a"
+        )
+        supervisor.send_msg.assert_called_once_with(OKResponse(ok=True), request_id=7, error=None)
+
+    def test_set_by_uri(self, supervisor):
+        self._handle(
+            supervisor, SetAssetStateStoreByUri(uri="s3://bucket/a", key="watermark", value="2026-01-01")
+        )
+
+        supervisor.client.asset_state_store.set.assert_called_once_with(
+            key="watermark", value="2026-01-01", uri="s3://bucket/a"
+        )
+
+    def test_delete_by_name(self, supervisor):
+        self._handle(supervisor, DeleteAssetStateStoreByName(name="asset_a", key="watermark"))
+
+        supervisor.client.asset_state_store.delete.assert_called_once_with(key="watermark", name="asset_a")
+
+    def test_delete_by_uri(self, supervisor):
+        self._handle(supervisor, DeleteAssetStateStoreByUri(uri="s3://bucket/a", key="watermark"))
+
+        supervisor.client.asset_state_store.delete.assert_called_once_with(
+            key="watermark", uri="s3://bucket/a"
+        )
+
+    def test_clear_by_name(self, supervisor):
+        self._handle(supervisor, ClearAssetStateStoreByName(name="asset_a"))
+
+        supervisor.client.asset_state_store.clear.assert_called_once_with(name="asset_a")
+
+    def test_clear_by_uri(self, supervisor):
+        self._handle(supervisor, ClearAssetStateStoreByUri(uri="s3://bucket/a"))
+
+        supervisor.client.asset_state_store.clear.assert_called_once_with(uri="s3://bucket/a")

Review Comment:
   These are missing asserts about `OKResponse` being called. `test_set_by_name` handles it well.



##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_asset_state_store.py:
##########
@@ -380,3 +380,66 @@ def test_get_inactive_asset_by_name_returns_404(self, client: TestClient, inacti
     def test_get_inactive_asset_by_uri_returns_404(self, client: TestClient, inactive_asset: AssetModel):
         response = client.get(_BY_URI_VALUE, params={"uri": inactive_asset.uri, "key": "watermark"})
         assert response.status_code == 404
+
+
+class TestPutAssetStateWatcherWrite:
+    """PUT routes record WATCHER kind when no TI backs the token (WATCHER/triggerer path)."""
+
+    @pytest.fixture(autouse=True)
+    def setup_null_uuid_auth(self, exec_app: FastAPI):
+        from uuid import UUID
+
+        async def _watcher_auth(request: Request) -> TIToken:
+            return TIToken(
+                id=UUID("00000000-0000-0000-0000-000000000000"), claims=TIClaims(scope="execution")
+            )
+
+        exec_app.dependency_overrides[require_auth] = _watcher_auth
+
+    def test_put_by_name_creates_row(self, client: TestClient, asset: AssetModel, session):
+        response = client.put(
+            _BY_NAME_VALUE, params={"name": asset.name, "key": "watermark"}, json={"value": "2026-01-01"}
+        )
+
+        assert response.status_code == 204
+        row = session.scalar(
+            select(AssetStateStoreModel).where(
+                AssetStateStoreModel.asset_id == asset.id,
+                AssetStateStoreModel.key == "watermark",
+            )
+        )
+        assert row is not None
+        assert row.value == '"2026-01-01"'
+
+    def test_put_by_name_records_watcher_kind(self, client: TestClient, asset: AssetModel, session):
+        client.put(
+            _BY_NAME_VALUE, params={"name": asset.name, "key": "watermark"}, json={"value": "2026-01-01"}
+        )
+
+        row = session.scalar(
+            select(AssetStateStoreModel).where(
+                AssetStateStoreModel.asset_id == asset.id,
+                AssetStateStoreModel.key == "watermark",
+            )
+        )
+        assert row is not None
+        assert row.last_updated_by_kind == "watcher"
+        assert row.last_updated_by_dag_id is None
+        assert row.last_updated_by_run_id is None
+        assert row.last_updated_by_task_id is None
+        assert row.last_updated_by_map_index is None
+
+    def test_put_by_uri_records_watcher_kind(self, client: TestClient, asset: AssetModel, session):
+        response = client.put(
+            _BY_URI_VALUE, params={"uri": asset.uri, "key": "watermark"}, json={"value": "2026-06-01"}
+        )
+
+        assert response.status_code == 204
+        row = session.scalar(
+            select(AssetStateStoreModel).where(
+                AssetStateStoreModel.asset_id == asset.id,
+                AssetStateStoreModel.key == "watermark",
+            )
+        )
+        assert row is not None
+        assert row.last_updated_by_kind == "watcher"

Review Comment:
   We should assert that other fields are none to have a strong test here, check the test above that does it



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3460925533


##########
task-sdk/src/airflow/sdk/execution_time/request_handlers.py:
##########


Review Comment:
   @vincbeck - what is the suggestion here? I'd lean away from using this PR to introduce tests for this entire file.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3467036384


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########


Review Comment:
   Sounds good, I can create an issue for this.



##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########


Review Comment:
   Resolving convo for now, but will circle back.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3464513756


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########


Review Comment:
   @jroachgolf84 if you could probably create a ticket for it?
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3467060754


##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -834,6 +845,94 @@ async def test_create_triggers_asset_state_store_accessor_reads_and_writes(
     await runner.cleanup_finished_triggers()
 
 
+class TestTriggerSupervisorAssetStateStore:
+    """Supervisor side of the asset-state-store round trip.
+
+    The accessor-only test above asserts the messages a watcher trigger emits, but never
+    exercises ``TriggerRunnerSupervisor._handle_request``. These drive the supervisor
+    directly so a broken (or missing) branch can't pass silently.
+    """
+
+    @pytest.fixture
+    def supervisor(self, jobless_supervisor, mocker):
+        jobless_supervisor.client = mocker.MagicMock(spec=Client)
+        mocker.patch.object(TriggerRunnerSupervisor, "send_msg")
+        return jobless_supervisor
+
+    @staticmethod
+    def _handle(supervisor, msg):
+        supervisor._handle_request(msg, log=MagicMock(spec=FilteringBoundLogger), req_id=7)
+
+    def test_get_by_name_wraps_response_and_replies(self, supervisor):
+        supervisor.client.asset_state_store.get.return_value = AssetStateStoreResponse(value="2026-01-01")
+
+        self._handle(supervisor, GetAssetStateStoreByName(name="asset_a", key="watermark"))
+
+        supervisor.client.asset_state_store.get.assert_called_once_with(key="watermark", name="asset_a")
+        supervisor.send_msg.assert_called_once_with(
+            AssetStateStoreResult(value="2026-01-01"), request_id=7, error=None
+        )
+
+    def test_get_by_uri_wraps_response_and_replies(self, supervisor):
+        supervisor.client.asset_state_store.get.return_value = AssetStateStoreResponse(value="2026-01-01")
+
+        self._handle(supervisor, GetAssetStateStoreByUri(uri="s3://bucket/a", key="watermark"))
+
+        supervisor.client.asset_state_store.get.assert_called_once_with(key="watermark", uri="s3://bucket/a")
+        supervisor.send_msg.assert_called_once_with(
+            AssetStateStoreResult(value="2026-01-01"), request_id=7, error=None
+        )
+
+    def test_get_passes_through_not_found_error(self, supervisor):
+        err = ErrorResponse(error=ErrorType.ASSET_STORE_NOT_FOUND, detail={"key": "watermark"})
+        supervisor.client.asset_state_store.get.return_value = err
+
+        self._handle(supervisor, GetAssetStateStoreByName(name="asset_a", key="watermark"))
+
+        supervisor.send_msg.assert_called_once_with(err, request_id=7, error=None)
+
+    def test_set_by_name(self, supervisor):
+        self._handle(
+            supervisor, SetAssetStateStoreByName(name="asset_a", key="watermark", value="2026-01-01")
+        )
+
+        supervisor.client.asset_state_store.set.assert_called_once_with(
+            key="watermark", value="2026-01-01", name="asset_a"
+        )
+        supervisor.send_msg.assert_called_once_with(OKResponse(ok=True), request_id=7, error=None)
+
+    def test_set_by_uri(self, supervisor):
+        self._handle(
+            supervisor, SetAssetStateStoreByUri(uri="s3://bucket/a", key="watermark", value="2026-01-01")
+        )
+
+        supervisor.client.asset_state_store.set.assert_called_once_with(
+            key="watermark", value="2026-01-01", uri="s3://bucket/a"
+        )
+
+    def test_delete_by_name(self, supervisor):
+        self._handle(supervisor, DeleteAssetStateStoreByName(name="asset_a", key="watermark"))
+
+        supervisor.client.asset_state_store.delete.assert_called_once_with(key="watermark", name="asset_a")
+
+    def test_delete_by_uri(self, supervisor):
+        self._handle(supervisor, DeleteAssetStateStoreByUri(uri="s3://bucket/a", key="watermark"))
+
+        supervisor.client.asset_state_store.delete.assert_called_once_with(
+            key="watermark", uri="s3://bucket/a"
+        )
+
+    def test_clear_by_name(self, supervisor):
+        self._handle(supervisor, ClearAssetStateStoreByName(name="asset_a"))
+
+        supervisor.client.asset_state_store.clear.assert_called_once_with(name="asset_a")
+
+    def test_clear_by_uri(self, supervisor):
+        self._handle(supervisor, ClearAssetStateStoreByUri(uri="s3://bucket/a"))
+
+        supervisor.client.asset_state_store.clear.assert_called_once_with(uri="s3://bucket/a")

Review Comment:
   Resolved in next commit.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3472087663


##########
airflow-core/docs/core-concepts/asset-state-store.rst:
##########
@@ -150,6 +150,80 @@ Deletes *all* asset state store keys for the asset.
     # Using context
     context["asset_state_store"][my_asset].clear()
 
+Using ``asset_state_store`` inside a Watcher Trigger
+-----------------------------------------------------
+
+:class:`~airflow.triggers.base.BaseEventTrigger` subclasses (watcher triggers) can read and write asset state store directly from within ``run()``. The triggerer injects ``self.asset_state_store`` before ``run()`` is called, scoped to the asset the trigger is watching.

Review Comment:
   ```suggestion
   :class:`~airflow.triggers.base.BaseEventTrigger` subclasses (watcher triggers) can read and write asset state store directly from within ``run()``. The triggerer injects ``self.asset_state_store`` before ``run()`` is called, scoped to the asset the trigger is watching. It is not available during ``__init__`` or ``serialize()``, only access it from within ``run()``.
   ```



##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/asset_state_store.py:
##########
@@ -130,18 +132,31 @@ def _put_asset_state_store(
 ) -> None:
     backend = get_state_backend()
     if isinstance(backend, MetastoreBackend):
-        dag_id, run_id, task_id, map_index = _fetch_ti_writer_fields(token, session)
-        backend.set_asset_state_store(
-            scope,
-            key,
-            json.dumps(body.value),
-            kind=AssetStateStoreWriterKind.TASK,
-            dag_id=dag_id,
-            run_id=run_id,
-            task_id=task_id,
-            map_index=map_index,
-            session=session,
-        )
+        if token.id == NULL_UUID:
+            # A watcher trigger writing via the triggerer's in-process client has a null-UUID

Review Comment:
   ```suggestion
               # Since the asset state store routes do not have `task_instance_id` in their path params, the default kicks in which is"00000000-0000-0000-0000-000000000000"
   ```



##########
task-sdk/tests/task_sdk/execution_time/test_request_handlers.py:
##########
@@ -0,0 +1,167 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from unittest.mock import MagicMock
+
+import pytest
+
+from airflow.sdk.api import client as sdk_client
+from airflow.sdk.api.datamodels._generated import AssetStateStoreResponse
+from airflow.sdk.exceptions import ErrorType
+from airflow.sdk.execution_time.comms import (
+    AssetStateStoreResult,
+    ClearAssetStateStoreByName,
+    ClearAssetStateStoreByUri,
+    DeleteAssetStateStoreByName,
+    DeleteAssetStateStoreByUri,
+    ErrorResponse,
+    GetAssetStateStoreByName,
+    GetAssetStateStoreByUri,
+    SetAssetStateStoreByName,
+    SetAssetStateStoreByUri,
+)
+from airflow.sdk.execution_time.request_handlers import (
+    handle_clear_asset_state_store_by_name,
+    handle_clear_asset_state_store_by_uri,
+    handle_delete_asset_state_store_by_name,
+    handle_delete_asset_state_store_by_uri,
+    handle_get_asset_state_store_by_name,
+    handle_get_asset_state_store_by_uri,
+    handle_set_asset_state_store_by_name,
+    handle_set_asset_state_store_by_uri,
+)
+
+
+@pytest.fixture
+def client():
+    return MagicMock(spec=sdk_client.Client)
+
+
+def test_get_asset_state_store_by_name_wraps_response_as_result(client):
+    client.asset_state_store.get.return_value = AssetStateStoreResponse(value="2026-01-01")
+
+    result, dump_opts = handle_get_asset_state_store_by_name(
+        client, GetAssetStateStoreByName(name="asset_a", key="watermark")
+    )
+
+    client.asset_state_store.get.assert_called_once_with(key="watermark", name="asset_a")
+    assert result == AssetStateStoreResult(value="2026-01-01")
+    assert dump_opts == {}
+
+
+def test_get_asset_state_store_by_name_passes_through_error_response(client):
+    err = ErrorResponse(error=ErrorType.ASSET_STORE_NOT_FOUND, detail={"key": "watermark"})
+    client.asset_state_store.get.return_value = err
+
+    result, dump_opts = handle_get_asset_state_store_by_name(
+        client, GetAssetStateStoreByName(name="asset_a", key="watermark")
+    )
+
+    assert result is err
+    assert dump_opts == {}
+
+
+def test_get_asset_state_store_by_uri_wraps_response_as_result(client):
+    client.asset_state_store.get.return_value = AssetStateStoreResponse(value="2026-01-01")
+
+    result, dump_opts = handle_get_asset_state_store_by_uri(
+        client, GetAssetStateStoreByUri(uri="s3://bucket/a", key="watermark")
+    )
+
+    client.asset_state_store.get.assert_called_once_with(key="watermark", uri="s3://bucket/a")
+    assert result == AssetStateStoreResult(value="2026-01-01")
+    assert dump_opts == {}
+
+
+def test_get_asset_state_store_by_uri_passes_through_error_response(client):
+    err = ErrorResponse(error=ErrorType.ASSET_STORE_NOT_FOUND, detail={"key": "watermark"})
+    client.asset_state_store.get.return_value = err
+
+    result, dump_opts = handle_get_asset_state_store_by_uri(
+        client, GetAssetStateStoreByUri(uri="s3://bucket/a", key="watermark")
+    )
+
+    assert result is err
+    assert dump_opts == {}
+
+
+@pytest.mark.parametrize(
+    ("handler", "msg", "call_kwargs", "method"),
+    [
+        (
+            handle_set_asset_state_store_by_name,
+            SetAssetStateStoreByName,
+            {
+                "name": "asset_a",
+                "key": "watermark",
+                "value": "2026-01-01",
+            },
+            "set",
+        ),
+        (
+            handle_set_asset_state_store_by_uri,
+            SetAssetStateStoreByUri,
+            {
+                "uri": "s3://bucket/a",
+                "key": "watermark",
+                "value": "2026-01-01",
+            },
+            "set",
+        ),
+        (
+            handle_delete_asset_state_store_by_name,
+            DeleteAssetStateStoreByName,
+            {
+                "name": "asset_a",
+                "key": "watermark",
+            },
+            "delete",
+        ),
+        (
+            handle_delete_asset_state_store_by_uri,
+            DeleteAssetStateStoreByUri,
+            {
+                "uri": "s3://bucket/a",
+                "key": "watermark",
+            },
+            "delete",
+        ),
+        (
+            handle_clear_asset_state_store_by_name,
+            ClearAssetStateStoreByName,
+            {
+                "name": "asset_a",
+            },
+            "clear",
+        ),
+        (
+            handle_clear_asset_state_store_by_uri,
+            ClearAssetStateStoreByUri,
+            {
+                "uri": "s3://bucket/a",
+            },
+            "clear",
+        ),
+    ],
+)
+def test_asset_store_store_delegates_to_client(client, handler, msg, call_kwargs, method):

Review Comment:
   ```suggestion
   def test_asset_store_delegates_to_client(client, handler, msg, call_kwargs, method):
   ```



##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/asset_state_store.py:
##########
@@ -130,18 +132,31 @@ def _put_asset_state_store(
 ) -> None:
     backend = get_state_backend()
     if isinstance(backend, MetastoreBackend):
-        dag_id, run_id, task_id, map_index = _fetch_ti_writer_fields(token, session)
-        backend.set_asset_state_store(
-            scope,
-            key,
-            json.dumps(body.value),
-            kind=AssetStateStoreWriterKind.TASK,
-            dag_id=dag_id,
-            run_id=run_id,
-            task_id=task_id,
-            map_index=map_index,
-            session=session,
-        )
+        if token.id == NULL_UUID:
+            # A watcher trigger writing via the triggerer's in-process client has a null-UUID
+            backend.set_asset_state_store(
+                scope,
+                key,
+                json.dumps(body.value),
+                kind=AssetStateStoreWriterKind.WATCHER,
+                session=session,
+            )
+        else:
+            # Retrieve TI fields, since token.id is not NULL_UUID

Review Comment:
   ```suggestion
   ```



##########
airflow-core/docs/core-concepts/asset-state-store.rst:
##########
@@ -150,6 +150,80 @@ Deletes *all* asset state store keys for the asset.
     # Using context
     context["asset_state_store"][my_asset].clear()
 
+Using ``asset_state_store`` inside a Watcher Trigger
+-----------------------------------------------------
+
+:class:`~airflow.triggers.base.BaseEventTrigger` subclasses (watcher triggers) can read and write asset state store directly from within ``run()``. The triggerer injects ``self.asset_state_store`` before ``run()`` is called, scoped to the asset the trigger is watching.
+
+Unlike task-based access (where the asset is identified by an inlet or outlet declaration), the accessor in a watcher trigger is automatically bound to the watched asset, so no subscripting is needed.
+
+.. code-block:: python
+
+    import asyncio
+    from collections.abc import AsyncIterator
+    from typing import Any
+
+    from airflow.triggers.base import BaseEventTrigger, TriggerEvent
+
+
+    class PollEventsTrigger(BaseEventTrigger):
+        def __init__(self, source: str, waiter_delay: int, **kwargs):
+            super().__init__(**kwargs)
+            self.source = source
+            self.waiter_delay = waiter_delay
+
+        def serialize(self) -> tuple[str, dict[str, Any]]:
+            return (
+                f"{self.__class__.__module__}.{self.__class__.__qualname__}",
+                {"source": self.source, "waiter_delay": self.waiter_delay},
+            )
+
+        def _poll_for_new_record(self, source: str, last_seen: str) -> str | None:
+            ...  # Add logic for polling a certain source
+            return None
+
+        async def run(self) -> AsyncIterator[TriggerEvent]:
+            while True:
+                last_seen = self.asset_state_store.get("last_seen_id", default=0)
+                new_id = self._poll_for_new_record(
+                    source=self.source,
+                    last_seen=last_seen,
+                )
+
+                if new_id is not None:
+                    self.asset_state_store.set("last_seen_id", new_id)
+                    yield TriggerEvent({"status": "success", "record_id": new_id})
+                    return
+
+                await asyncio.sleep(self.waiter_delay)
+
+The corresponding :class:`~airflow.sdk.definitions.asset.AssetWatcher` wires the trigger to the asset:
+
+.. code-block:: python
+
+    from airflow.sdk import Asset, AssetWatcher
+
+    # Import trigger from internal module (wherever it was written)

Review Comment:
   ```suggestion
       from my_dag.triggers import PollEventsTrigger
   ```
   
   That's too informal, sounds like a todo, not something we want in docs.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3460821347


##########
task-sdk/src/airflow/sdk/execution_time/request_handlers.py:
##########


Review Comment:
   This file has no unit test associated. Even though they might be covered by some other upper level tests, it is still worth having unit tests at the module level



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3460965798


##########
task-sdk/src/airflow/sdk/execution_time/request_handlers.py:
##########


Review Comment:
   At least tests for the functions you are adding



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3464512629


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########


Review Comment:
   The greenback path already works, and calling `asset_state_store.get()/set()` from `async def run()` will function correctly as long as the greenback portal is active.
   
   The only scenario where it breaks is `AIRFLOW_DISABLE_GREENBACK_PORTAL=true`, which is a non default, opted out configuration. And in that case the error message already tells you to use async equivalents I think, but the gap is just that no async equivalents exist yet for `asset_state_store` yet, worth adding that in a follow up, similar to: https://github.com/apache/airflow/pull/68232/



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on PR #68900:
URL: https://github.com/apache/airflow/pull/68900#issuecomment-4789710637

   @amoghrajesh - all feedback has been implemented!


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3467071368


##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_asset_state_store.py:
##########
@@ -380,3 +380,66 @@ def test_get_inactive_asset_by_name_returns_404(self, client: TestClient, inacti
     def test_get_inactive_asset_by_uri_returns_404(self, client: TestClient, inactive_asset: AssetModel):
         response = client.get(_BY_URI_VALUE, params={"uri": inactive_asset.uri, "key": "watermark"})
         assert response.status_code == 404
+
+
+class TestPutAssetStateWatcherWrite:
+    """PUT routes record WATCHER kind when no TI backs the token (WATCHER/triggerer path)."""
+
+    @pytest.fixture(autouse=True)
+    def setup_null_uuid_auth(self, exec_app: FastAPI):
+        from uuid import UUID
+
+        async def _watcher_auth(request: Request) -> TIToken:
+            return TIToken(
+                id=UUID("00000000-0000-0000-0000-000000000000"), claims=TIClaims(scope="execution")
+            )
+
+        exec_app.dependency_overrides[require_auth] = _watcher_auth
+
+    def test_put_by_name_creates_row(self, client: TestClient, asset: AssetModel, session):
+        response = client.put(
+            _BY_NAME_VALUE, params={"name": asset.name, "key": "watermark"}, json={"value": "2026-01-01"}
+        )
+
+        assert response.status_code == 204
+        row = session.scalar(
+            select(AssetStateStoreModel).where(
+                AssetStateStoreModel.asset_id == asset.id,
+                AssetStateStoreModel.key == "watermark",
+            )
+        )
+        assert row is not None
+        assert row.value == '"2026-01-01"'
+
+    def test_put_by_name_records_watcher_kind(self, client: TestClient, asset: AssetModel, session):
+        client.put(
+            _BY_NAME_VALUE, params={"name": asset.name, "key": "watermark"}, json={"value": "2026-01-01"}
+        )
+
+        row = session.scalar(
+            select(AssetStateStoreModel).where(
+                AssetStateStoreModel.asset_id == asset.id,
+                AssetStateStoreModel.key == "watermark",
+            )
+        )
+        assert row is not None
+        assert row.last_updated_by_kind == "watcher"
+        assert row.last_updated_by_dag_id is None
+        assert row.last_updated_by_run_id is None
+        assert row.last_updated_by_task_id is None
+        assert row.last_updated_by_map_index is None
+
+    def test_put_by_uri_records_watcher_kind(self, client: TestClient, asset: AssetModel, session):
+        response = client.put(
+            _BY_URI_VALUE, params={"uri": asset.uri, "key": "watermark"}, json={"value": "2026-06-01"}
+        )
+
+        assert response.status_code == 204
+        row = session.scalar(
+            select(AssetStateStoreModel).where(
+                AssetStateStoreModel.asset_id == asset.id,
+                AssetStateStoreModel.key == "watermark",
+            )
+        )
+        assert row is not None
+        assert row.last_updated_by_kind == "watcher"

Review Comment:
   Resolved in next commit.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #68900:
URL: https://github.com/apache/airflow/pull/68900#issuecomment-4796190364

   Actually let me just apply the suggestions.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3467237060


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/asset_state_store.py:
##########
@@ -51,8 +51,8 @@
 _TIWriterFields = tuple[str, str, str, int]
 
 
-def _fetch_ti_writer_fields(token: TIToken, session: SessionDep) -> _TIWriterFields:
-    """Return (dag_id, run_id, task_id, map_index) for the TI identified by the token."""

Review Comment:
   Resolved in next commit.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3460007000


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -622,6 +648,25 @@ def _handle_request(self, msg: ToTriggerSupervisor, log: FilteringBoundLogger, r
             resp = HITLDetailResponseResult.from_api_response(response=api_resp)
         elif isinstance(msg, MaskSecret):
             handle_mask_secret(msg)
+
+        # Adding AssetStateStore functionality

Review Comment:
   ```suggestion
   ```



##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -834,6 +843,94 @@ async def test_create_triggers_asset_state_store_accessor_reads_and_writes(
     await runner.cleanup_finished_triggers()
 
 
+class TestTriggerSupervisorAssetStateStore:
+    """Supervisor side of the asset-state-store round trip.
+
+    The accessor-only test above asserts the messages a watcher trigger emits, but never
+    exercises ``TriggerRunnerSupervisor._handle_request``. These drive the supervisor
+    directly so a broken (or missing) branch can't pass silently.
+    """
+
+    @pytest.fixture
+    def supervisor(self, jobless_supervisor, mocker):
+        jobless_supervisor.client = mocker.MagicMock()

Review Comment:
   Here and elsewhere, can we please use `spec` or `autospec`?



##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -622,6 +648,25 @@ def _handle_request(self, msg: ToTriggerSupervisor, log: FilteringBoundLogger, r
             resp = HITLDetailResponseResult.from_api_response(response=api_resp)
         elif isinstance(msg, MaskSecret):
             handle_mask_secret(msg)
+
+        # Adding AssetStateStore functionality
+        elif isinstance(msg, ClearAssetStateStoreByName):
+            resp, dump_opts = handle_clear_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, ClearAssetStateStoreByUri):
+            resp, dump_opts = handle_clear_asset_state_store_by_uri(self.client, msg)
+        elif isinstance(msg, DeleteAssetStateStoreByName):
+            resp, dump_opts = handle_delete_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, DeleteAssetStateStoreByUri):
+            resp, dump_opts = handle_delete_asset_state_store_by_uri(self.client, msg)
+        elif isinstance(msg, GetAssetStateStoreByName):
+            resp, dump_opts = handle_get_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, GetAssetStateStoreByUri):
+            resp, dump_opts = handle_get_asset_state_store_by_uri(self.client, msg)
+        elif isinstance(msg, SetAssetStateStoreByName):
+            resp, dump_opts = handle_set_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, SetAssetStateStoreByUri):
+            resp, dump_opts = handle_set_asset_state_store_by_uri(self.client, msg)
+

Review Comment:
   ```suggestion
   ```



##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -622,6 +648,25 @@ def _handle_request(self, msg: ToTriggerSupervisor, log: FilteringBoundLogger, r
             resp = HITLDetailResponseResult.from_api_response(response=api_resp)
         elif isinstance(msg, MaskSecret):
             handle_mask_secret(msg)
+
+        # Adding AssetStateStore functionality
+        elif isinstance(msg, ClearAssetStateStoreByName):
+            resp, dump_opts = handle_clear_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, ClearAssetStateStoreByUri):
+            resp, dump_opts = handle_clear_asset_state_store_by_uri(self.client, msg)
+        elif isinstance(msg, DeleteAssetStateStoreByName):
+            resp, dump_opts = handle_delete_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, DeleteAssetStateStoreByUri):
+            resp, dump_opts = handle_delete_asset_state_store_by_uri(self.client, msg)
+        elif isinstance(msg, GetAssetStateStoreByName):
+            resp, dump_opts = handle_get_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, GetAssetStateStoreByUri):
+            resp, dump_opts = handle_get_asset_state_store_by_uri(self.client, msg)
+        elif isinstance(msg, SetAssetStateStoreByName):
+            resp, dump_opts = handle_set_asset_state_store_by_name(self.client, msg)
+        elif isinstance(msg, SetAssetStateStoreByUri):
+            resp, dump_opts = handle_set_asset_state_store_by_uri(self.client, msg)
+

Review Comment:
   ```suggestion
           elif isinstance(msg, ClearAssetStateStoreByName):
               handle_clear_asset_state_store_by_name(self.client, msg)
               resp = OKResponse(ok=True)
           elif isinstance(msg, ClearAssetStateStoreByUri):
               handle_clear_asset_state_store_by_uri(self.client, msg)
               resp = OKResponse(ok=True)
           elif isinstance(msg, DeleteAssetStateStoreByName):
               handle_delete_asset_state_store_by_name(self.client, msg)
               resp = OKResponse(ok=True)
           elif isinstance(msg, DeleteAssetStateStoreByUri):
               handle_delete_asset_state_store_by_uri(self.client, msg)
               resp = OKResponse(ok=True)
           elif isinstance(msg, GetAssetStateStoreByName):
               resp, dump_opts = handle_get_asset_state_store_by_name(self.client, msg)
           elif isinstance(msg, GetAssetStateStoreByUri):
               resp, dump_opts = handle_get_asset_state_store_by_uri(self.client, msg)
           elif isinstance(msg, SetAssetStateStoreByName):
               handle_set_asset_state_store_by_name(self.client, msg)
               resp = OKResponse(ok=True)
           elif isinstance(msg, SetAssetStateStoreByUri):
               handle_set_asset_state_store_by_uri(self.client, msg)
               resp = OKResponse(ok=True)
   ```
   The handlers (`set`, `delete`, `clear`) return `(None, {})`, so `resp` stays `None` after these calls. `supervisor.py` explicitly sets `resp = OKResponse(ok=True). Suggest aligning with that
   



##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########


Review Comment:
   @kaxil, following up on your sync_to_async concern from https://github.com/apache/airflow/pull/67839#discussion_r3439491205: `TriggerCommsDecoder.send()` already handles the async case via `greenback.await_()`, so there's no deadlock under normal conditions as I see it. Does that make sense or were you pointing at a different gap?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3467163211


##########
task-sdk/tests/task_sdk/execution_time/test_request_handlers.py:
##########


Review Comment:
   Resolved in next commit.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3460311465


##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -834,6 +843,94 @@ async def test_create_triggers_asset_state_store_accessor_reads_and_writes(
     await runner.cleanup_finished_triggers()
 
 
+class TestTriggerSupervisorAssetStateStore:
+    """Supervisor side of the asset-state-store round trip.
+
+    The accessor-only test above asserts the messages a watcher trigger emits, but never
+    exercises ``TriggerRunnerSupervisor._handle_request``. These drive the supervisor
+    directly so a broken (or missing) branch can't pass silently.
+    """
+
+    @pytest.fixture
+    def supervisor(self, jobless_supervisor, mocker):
+        jobless_supervisor.client = mocker.MagicMock()

Review Comment:
   Cannot add `autospec` to `mocker.patch.object(TriggerRunnerSupervisor, "send_msg")`. Assertions get quite ugly.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #68900:
URL: https://github.com/apache/airflow/pull/68900#issuecomment-4796939303

   ### Backport successfully created: v3-3-test
   
   Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
   the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
   
   In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
   
   <table>
           <tr>
           <th>Status</th>
           <th>Branch</th>
           <th>Result</th>
       </tr>
       <tr>
           <td>✅</td>
           <td>v3-3-test</td>
           <td><a href="https://github.com/apache/airflow/pull/68966"><img src="https://img.shields.io/badge/PR-68966-blue" alt="PR Link"></a></td>
       </tr>
   </table>


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh merged PR #68900:
URL: https://github.com/apache/airflow/pull/68900


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3460315642


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -622,6 +648,25 @@ def _handle_request(self, msg: ToTriggerSupervisor, log: FilteringBoundLogger, r
             resp = HITLDetailResponseResult.from_api_response(response=api_resp)
         elif isinstance(msg, MaskSecret):
             handle_mask_secret(msg)
+
+        # Adding AssetStateStore functionality

Review Comment:
   Resolved in other commit suggestion.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on PR #68900:
URL: https://github.com/apache/airflow/pull/68900#issuecomment-4779998346

   @amoghrajesh - changes have been implemented.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AIP-103: Allow for `get`/`set`/`delete`/`clear` to run for `AssetStateStoreAccessor` on Triggerer [airflow]

Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on code in PR #68900:
URL: https://github.com/apache/airflow/pull/68900#discussion_r3460193688


##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -834,6 +843,94 @@ async def test_create_triggers_asset_state_store_accessor_reads_and_writes(
     await runner.cleanup_finished_triggers()
 
 
+class TestTriggerSupervisorAssetStateStore:
+    """Supervisor side of the asset-state-store round trip.
+
+    The accessor-only test above asserts the messages a watcher trigger emits, but never
+    exercises ``TriggerRunnerSupervisor._handle_request``. These drive the supervisor
+    directly so a broken (or missing) branch can't pass silently.
+    """
+
+    @pytest.fixture
+    def supervisor(self, jobless_supervisor, mocker):
+        jobless_supervisor.client = mocker.MagicMock()

Review Comment:
   Will resolve in next commit.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org