kevinalh commented on code in PR #38015:
URL: https://github.com/apache/airflow/pull/38015#discussion_r1527170374


##########
airflow/decorators/base.py:
##########
@@ -208,11 +208,35 @@ def __init__(
         # since values for those will be provided when the task is run. Since
         # we're not actually running the function, None is good enough here.
         signature = inspect.signature(python_callable)
+
+        # Don't allow context argument defaults other than None to avoid 
ambiguities.
+        if any(
+            param.name in KNOWN_CONTEXT_KEYS and param.default not in (None, 
inspect.Parameter.empty)
+            for param in signature.parameters.values()
+        ):
+            raise ValueError("Context key parameters can't have a default 
other than None")

Review Comment:
   New error message:
   
   ```
   ValueError: Context key parameter logical_date can't have a default other 
than None
   ```
   
   Definitely helps debugging. We could also make it print all (or a subset) of 
distinct faulty context key parameters, but this should be enough in my 
opinion. What do you think?
   



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