Copilot commented on code in PR #70859:
URL: https://github.com/apache/airflow/pull/70859#discussion_r3692248338


##########
providers/google/src/airflow/providers/google/cloud/sensors/cloud_composer.py:
##########
@@ -632,6 +595,42 @@ def _handle_skipped_states(self, skipped_status: bool) -> 
None:
             )
 
     def execute(self, context: Context) -> None:
+        # Validate and normalize the target only after its template fields 
have been rendered.
+        if self.composer_external_task_id is not None and 
self.composer_external_task_ids is not None:
+            raise ValueError(
+                "Only one of `composer_external_task_id` or 
`composer_external_task_ids` may "
+                "be provided to CloudComposerExternalTaskSensor; "
+                "use `composer_external_task_id` or 
`composer_external_task_ids` or `composer_external_task_group_id`."
+            )
+        if self.composer_external_task_group_id is not None and (
+            self.composer_external_task_id is not None or 
self.composer_external_task_ids is not None
+        ):
+            raise ValueError(
+                "Only one of `composer_external_task_group_id` or 
`composer_external_task_ids` may "
+                "be provided to CloudComposerExternalTaskSensor; "
+                "use `composer_external_task_id` or 
`composer_external_task_ids` or `composer_external_task_group_id`."
+            )
+
+        if not self.composer_external_task_ids:
+            self.composer_external_task_ids = None
+        if self.composer_external_task_id is not None:
+            self.composer_external_task_ids = [self.composer_external_task_id]

Review Comment:
   The mutual-exclusivity checks run before the empty-list → None 
normalization. This changes behavior from the previous implementation: e.g. 
`composer_external_task_group_id=...` with `composer_external_task_ids=[]` (or 
`composer_external_task_id=...` with `composer_external_task_ids=[]`) will now 
raise, even though `[]` is intended to normalize to `None`. Normalize 
`composer_external_task_ids` before doing the `is not None` exclusivity checks 
(and consider adding a regression test for the empty-list case).



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