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


##########
airflow/models/expandinput.py:
##########
@@ -245,12 +245,20 @@ def get_total_map_length(self, run_id: str, *, session: 
Session) -> int:
             raise NotFullyPopulated({"expand_kwargs() argument"})
         return value
 
-    def resolve(self, context: Context, session: Session) -> dict[str, Any]:
+    def resolve(self, context: Context, session: Session) -> Mapping[str, Any]:
         map_index = context["ti"].map_index
         if map_index < 0:
             raise RuntimeError("can't resolve task-mapping argument without 
expanding")
-        # Validation should be done when the upstream returns.
-        return self.value.resolve(context, session)[map_index]
+        mappings = self.value.resolve(context, session)
+        if not isinstance(mappings, collections.abc.Sequence):
+            raise ValueError(f"expand_kwargs() expects a list[dict], not 
{type(mappings).__name__}")
+        mapping = mappings[map_index]
+        if not isinstance(mapping, collections.abc.Mapping):
+            raise ValueError(f"expand_kwargs() expects a list[dict], not 
list[{type(mapping).__name__}]")
+        for key in mapping:
+            if not isinstance(key, str):
+                raise ValueError(f"expand_kwargs() input dict keys must be 
str, not {type(key).__name__}")

Review Comment:
   No because that can potentially be a huge list.



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