uranusjr commented on code in PR #37736:
URL: https://github.com/apache/airflow/pull/37736#discussion_r1512996161


##########
airflow/providers/google/cloud/operators/bigquery.py:
##########
@@ -2768,11 +2772,27 @@ def prepare_template(self) -> None:
             with open(self.configuration) as file:
                 self.configuration = json.loads(file.read())
 
+    def _add_job_labels(self) -> None:
+        dag_label = self.dag_id.lower()
+        task_label = self.task_id.lower()
+
+        if len(dag_label) <= LABEL_SIZE_LIMIT and len(task_label) <= 
LABEL_SIZE_LIMIT:
+            if LABEL_REGEX.match(dag_label) and LABEL_REGEX.match(task_label):
+                if "labels" in self.configuration:
+                    if isinstance(self.configuration["labels"], dict):

Review Comment:
   These checks are too naiveā€”I would instead do something like
   
   ```python
   try:
       self.configuration["labels"].upgrade({"airflow-dag": dag_label, 
"airflow-task": task_label})
   except (KeyError, TypeError, ValueError):
       self.configuration["labels"] = {"airflow-dag": dag_label, 
"airflow-task": task_label}
   ```



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to