jabbera opened a new issue, #55524:
URL: https://github.com/apache/airflow/issues/55524

   ### Apache Airflow version
   
   3.0.6
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   The following code:
   
   ```
   try:
       from airflow.sdk import task, DAG
   except ImportError:
       from airflow.decorators import task
       from airflow.models import DAG
   
   
   @task()
   def test_task(start_date, required_arg) -> None:
       pass
   
   
   with DAG(dag_id="example_dag") as dag:
       test_task("2023-01-01", "value")
   ```
   
   Generates this error:
   
   ```
   The function signature broke while assigning defaults to context key 
parameters.
   
   The decorator is replacing the signature
   > test_task(start_date, required_arg)
   
   with
   > test_task(start_date=None, required_arg)
   
   which isn't valid: non-default argument follows default argument.
   ```
   
   This works fine in airflow 2.10.
   
   Note: we happen to have a function argument named start_date here, we are 
NOT trying to use the template variable here.
   
   The error is generated because the decorator indiscriminately sets a default 
(None) for every parameter whose name matches a template variable: 
   
   
https://github.com/apache/airflow/blob/c9100bbbc60fd886691309b4bafc9069b7abbf0f/task-sdk/src/airflow/sdk/bases/decorator.py#L209-L212
   
   IMO: The default should only be set if there isn't a positional or named 
parameter that already sets a value for a given parameter. 
   
   Fixing this on our end would be monumental because it would require the 
rename of quite a few parameters across our entire ecosystem.
   
   
   
   
   ### What you think should happen instead?
   
   The dag should behave like airflow 2.X
   
   ### How to reproduce
   
   See above
   
   ### Operating System
   
   Ubuntu 24,.04 or WSL debian
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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