vincbeck commented on code in PR #77046:
URL: https://github.com/apache/airflow/pull/77046#discussion_r4601611666
##########
providers/common/messaging/src/airflow/providers/common/messaging/triggers/msg_queue.py:
##########
@@ -68,32 +68,47 @@ class MessageQueueTrigger(BaseEventTrigger):
def __init__(
self,
*,
- queue: str | None = None,
scheme: str | None = None,
+ queue: str | None = None,
trigger_queue: str | None = None,
**kwargs: Any,
) -> None:
- # Stored under our own name rather than through
`BaseEventTrigger.__init__(queue=...)` so this
- # works regardless of the installed airflow-core version, see `queue`
property below.
- self._trigger_queue = trigger_queue
-
- if queue is None and scheme is None:
- raise ValueError("Either `queue` or `scheme` parameter must be
provided.")
-
- # For backward compatibility, queue takes precedence
- if queue is not None:
+ if queue is not None and (
+ scheme is None or any(provider.queue_matches(queue) for provider
in MESSAGE_QUEUE_PROVIDERS)
+ ):
Review Comment:
My earlier suggestion missed a case: a broker URI that no installed provider
matches now silently becomes the trigger queue. Example:
`MessageQueueTrigger(scheme="redis+pubsub",
queue="redis+pubsub://localhost:6379/ch", channels=["ch"])`. Redis does not
override `queue_matches`, so the URI becomes the trigger queue with no warning,
and since triggerers without `--queues` only pick up triggers with no queue,
the asset watcher never runs (before this PR it failed at Dag parsing). Fix:
keep the `://` check next to `queue_matches`, plus a test for it.
```suggestion
if queue is not None and (
scheme is None
or "://" in queue
or any(provider.queue_matches(queue) for provider in
MESSAGE_QUEUE_PROVIDERS)
):
```
##########
devel-common/src/tests_common/test_utils/common_msg_queue.py:
##########
@@ -29,7 +29,7 @@ def collect_queue_param_deprecation_warning():
"""Collect deprecation warnings for queue parameter."""
with pytest.warns(
AirflowProviderDeprecationWarning,
- match="The `queue` parameter is deprecated and will be removed in
future versions. Use the `scheme` parameter instead and pass configuration as
keyword arguments to `MessageQueueTrigger`.",
+ match=r"(The `queue` parameter is deprecated|Passing the broker queue
URI as `queue` is deprecated)",
Review Comment:
nit: is the first alternative still needed? Nothing emits that message
anymore.
```suggestion
match="Passing the broker queue URI as `queue` is deprecated",
```
--
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]