kaxil commented on code in PR #77614:
URL: https://github.com/apache/airflow/pull/77614#discussion_r4701178396


##########
airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_12_01.py:
##########
@@ -0,0 +1,47 @@
+# 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 cadwyn import RequestInfo, VersionChange, 
convert_request_to_next_version_for, schema
+from fastapi import HTTPException
+from pydantic import JsonValue
+
+from airflow.api_fastapi.compat import HTTP_422_UNPROCESSABLE_CONTENT
+from airflow.api_fastapi.execution_api.datamodels.taskinstance import 
TIDeferredStatePayload
+
+
+class RemoveStringTriggerKwargs(VersionChange):
+    """Stop accepting `trigger_kwargs` as a string in 
TIDeferredStatePayload."""
+
+    description = __doc__
+
+    instructions_to_migrate_to_previous_version = (
+        
schema(TIDeferredStatePayload).field("trigger_kwargs").had(type=dict[str, 
JsonValue] | str),
+    )
+
+    @convert_request_to_next_version_for(TIDeferredStatePayload)  # type: 
ignore[arg-type]

Review Comment:
   This converter is matched by body schema, and the state route's body is the 
`TIStateUpdate` union. Only Cadwyn 9 matches a single union member: on 8.2.0, 
which `v3-4-test` still locks (floor `cadwyn>=8.1.0`), building the versioned 
app raises `RouteRequestBySchemaConverterDoesNotApplyToAnythingError`, so the 
3.4.1 backport this date was picked for would break the whole Execution API. 
Keying it by path, 
`@convert_request_to_next_version_for("/task-instances/{task_instance_id}/state",
 ["PATCH"])`, works on both 8.2.0 and 9.0.0 (same approach as 
`/dag-runs/previous` in `v2026_06_30.py`). Can we switch to that?



##########
airflow-core/src/airflow/models/trigger.py:
##########
@@ -274,7 +273,11 @@ def rotate_fernet_key(self):
         """Encrypts data with a new key. See: :ref:`security/fernet`."""
         from airflow.crypto import get_fernet
 
-        self.encrypted_kwargs = 
get_fernet().rotate(self.encrypted_kwargs.encode("utf-8")).decode("utf-8")
+        fernet = get_fernet()
+        if self.encrypted_kwargs.startswith("{"):

Review Comment:
   This is now the third copy of the `startswith("{")` plaintext check, next to 
`_decrypt_kwargs` above and the triggerer's `_encrypt_plaintext_kwargs`. Could 
the triggerer's re-encrypt become a public method on `Trigger` that both it and 
this branch call? Fine as a follow-up, since both paths already write rows that 
decrypt correctly.



##########
airflow-core/src/airflow/api_fastapi/execution_api/datamodels/taskinstance.py:
##########
@@ -180,23 +180,15 @@ class TIDeferredStatePayload(StrictBaseModel):
         ),
     ]
     classpath: str
-    trigger_kwargs: Annotated[dict[str, JsonValue] | str, 
Field(default_factory=dict)]
-    """
-    Kwargs to pass to the trigger constructor, either a plain dict or an 
encrypted string.
-
-    Both forms will be passed along to the trigger, the server will not handle 
either.
-    """
+    trigger_kwargs: Annotated[dict[str, JsonValue], 
Field(default_factory=dict)]
+    """Serde-encoded kwargs to pass to the trigger constructor. The server 
encrypts them before storing."""
 
     trigger_timeout: timedelta | None = None
     queue: str | None = None
     next_method: str
     """The name of the method on the operator to call in the worker after the 
trigger has fired."""
     next_kwargs: Annotated[dict[str, JsonValue], Field(default_factory=dict)]
-    """
-    Kwargs to pass to the above method, either a plain dict or an encrypted 
string.
-
-    Both forms will be passed along to the TaskSDK upon resume, the server 
will not handle either.
-    """
+    """Serde-encoded kwargs to pass to the above method, passed back to the 
TaskSDK as given upon resume."""

Review Comment:
   "As given" isn't quite right: `handle_event_submit` adds the event under 
`event` before the task resumes (same for the awaiting-input payload at line 
232). Maybe "...returned on resume with the event added under `event`"?



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