artsntech commented on code in PR #77472:
URL: https://github.com/apache/airflow/pull/77472#discussion_r4663792735
##########
airflow-core/src/airflow/models/trigger.py:
##########
@@ -218,8 +218,11 @@ def __init__(
@property
def kwargs(self) -> dict[str, Any]:
- """Return the decrypted kwargs of the trigger."""
- return self._decrypt_kwargs(self.encrypted_kwargs)
+ """Return the decrypted kwargs of the trigger, encrypting them if not
already encrypted."""
+ decrypted = self._decrypt_kwargs(self.encrypted_kwargs)
+ if self.encrypted_kwargs.startswith("{"):
+ self.encrypted_kwargs = self.encrypt_kwargs(decrypted)
+ return decrypted
Review Comment:
Good catch, thank you! Indeed, `TriggerRunnerSupervisor._create_workload`
reads `trigger.encrypted_kwargs` directly and `TriggerRunner` calls the static
`Trigger._decrypt_kwargs(...)`, so mutating inside the `Trigger.kwargs`
property wouldn't run on the triggerer path (nor persist without a session
commit).
I've moved the in-place encryption to
`TriggerRunnerSupervisor._create_workload` (similar to
`_record_missing_used_by`), where the supervisor has an active DB session that
commits the workload setup and passes the already-encrypted payload in
`RunTrigger`. Updated the unit tests and PR description accordingly.
--
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]