jscheffl commented on code in PR #52019:
URL: https://github.com/apache/airflow/pull/52019#discussion_r2160340075


##########
task-sdk/src/airflow/sdk/definitions/param.py:
##########
@@ -218,6 +218,27 @@ def __getitem__(self, key: str) -> Any:
         param = self.__dict[key]
         return param.resolve(suppress_exception=self.suppress_exception)
 
+    def get(self, key: str, default: Any = None) -> Any:
+        """
+        Get the value for a key, returning default if the key is not found OR 
if the resolved value is None.
+
+        This method properly handles the case where a parameter exists but has 
a None value,
+        which should be treated as if the key doesn't exist when a default is 
provided.
+
+        :param key: The key to fetch
+        :param default: The default value to return if key is not found or 
resolved value is None
+        """
+        try:
+            param = self.__dict[key]
+            resolved_value = 
param.resolve(suppress_exception=self.suppress_exception)
+            # If the resolved value is None and a default is provided, return 
the default
+            # This matches the expected behavior described in GitHub issue 
#51977
+            if resolved_value is None and default is not None:
+                return default

Review Comment:
   I dis-agree to this behavior change.
   If a param is defined using `None`as default by the Dag author, why should a 
method using define another default that overrides the previous.
   There might be good reasons having a parameter as `None` and also empty 
strings are passed as `None` and assuning a `.get()` provides another level of 
default potentially over-riding the explicitly passed `None` is wrong in my 
view.
   
   For me this is a different behavior and if somebody needs it it can be well 
achieved with other Python options like `params['key'] or 'default'` which make 
clear that you want to override the params default.



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