This is an automated email from the ASF dual-hosted git repository.
vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 5cd7afaf4f4 Add redis_conn_id to RedisKeySensor and RedisPubSubSensor
template_fields (#73018)
5cd7afaf4f4 is described below
commit 5cd7afaf4f467e4c5aa0d27212eee42e419c12b1
Author: Eddy ZHANG <[email protected]>
AuthorDate: Tue Sep 15 01:08:39 2026 +1000
Add redis_conn_id to RedisKeySensor and RedisPubSubSensor template_fields
(#73018)
Both sensors take `redis_conn_id` and use it to build the hook, but neither
lists
it in `template_fields`, so a Jinja expression passed as the connection id
is
never rendered and reaches `RedisHook` verbatim:
sensor = RedisKeySensor(key="k", redis_conn_id="redis_{{ ds }}", ...)
sensor.render_template_fields({"ds": "2017-01-01"})
sensor.redis_conn_id # 'redis_{{ ds }}' before this change
`RedisPublishOperator` got the same fix in #72883. These two sensors are
the only
other classes in the provider that declare `template_fields`, so this
completes
the redis slice of #35259.
No test, following the review on #72883 where the equivalent test was
removed
before merge.
---
providers/redis/src/airflow/providers/redis/sensors/redis_key.py | 8 ++++++--
.../redis/src/airflow/providers/redis/sensors/redis_pub_sub.py | 4 ++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/providers/redis/src/airflow/providers/redis/sensors/redis_key.py
b/providers/redis/src/airflow/providers/redis/sensors/redis_key.py
index e2c47c4357c..5c9a1fe3222 100644
--- a/providers/redis/src/airflow/providers/redis/sensors/redis_key.py
+++ b/providers/redis/src/airflow/providers/redis/sensors/redis_key.py
@@ -28,9 +28,13 @@ if TYPE_CHECKING:
class RedisKeySensor(BaseSensorOperator):
- """Checks for the existence of a key in a Redis."""
+ """
+ Checks for the existence of a key in a Redis.
- template_fields: Sequence[str] = ("key",)
+ :param redis_conn_id: the redis connection id (templated)
+ """
+
+ template_fields: Sequence[str] = ("key", "redis_conn_id")
ui_color = "#f0eee4"
def __init__(self, *, key: str, redis_conn_id: str, **kwargs) -> None:
diff --git
a/providers/redis/src/airflow/providers/redis/sensors/redis_pub_sub.py
b/providers/redis/src/airflow/providers/redis/sensors/redis_pub_sub.py
index 1c13afeabbe..a47b8172b35 100644
--- a/providers/redis/src/airflow/providers/redis/sensors/redis_pub_sub.py
+++ b/providers/redis/src/airflow/providers/redis/sensors/redis_pub_sub.py
@@ -33,10 +33,10 @@ class RedisPubSubSensor(BaseSensorOperator):
Redis sensor for reading a message from pub sub channels.
:param channels: The channels to be subscribed to (templated)
- :param redis_conn_id: the redis connection id
+ :param redis_conn_id: the redis connection id (templated)
"""
- template_fields: Sequence[str] = ("channels",)
+ template_fields: Sequence[str] = ("channels", "redis_conn_id")
ui_color = "#f0eee4"
def __init__(self, *, channels: list[str] | str, redis_conn_id: str,
**kwargs) -> None: