yuseok89 commented on code in PR #75499:
URL: https://github.com/apache/airflow/pull/75499#discussion_r4439561712


##########
airflow-core/src/airflow/partition_mappers/chain.py:
##########
@@ -66,8 +67,18 @@ def to_downstream(self, key: str) -> str | Iterable[str]:
         return keys[0] if len(keys) == 1 else keys
 
     def to_partition_date(self, downstream_key: str) -> datetime | None:
-        # The last mapper in the chain formats the final downstream key, so it 
owns the anchor.
-        return self.mappers[-1].to_partition_date(downstream_key)
+        # A trailing IdentityMapper preserves the key, so the previous mapper 
still owns the anchor.
+        mapper = self.mappers[-1]
+        index = len(self.mappers) - 1
+        while isinstance(mapper, IdentityMapper) and index > 0:
+            index -= 1
+            mapper = self.mappers[index]
+        try:
+            return mapper.to_partition_date(downstream_key)
+        except ValueError:

Review Comment:
   What would you expect from `ChainMapper(StartOfHourMapper(), 
StartOfDayMapper()).to_partition_date("not-a-date")`? On main it raises 
`ValueError`, which the trigger path turns into a 400 
`InvalidPartitionKeyError`, but here it returns `None`.



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