jedcunningham commented on code in PR #77614: URL: https://github.com/apache/airflow/pull/77614#discussion_r4701286580
########## 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: Good catch, switched to the path-keyed converter. Verified the version tests pass on both cadwyn 8.2.0 and 9.0.0. ########## 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: Updated both docstrings. ########## 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: Agreed, I'll consolidate them in a follow-up. -- 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]
