Repository navigation
Required Param requires None to be explicitly passed as default #28940
Description
Activity
Thanks for opening your first issue here! Be sure to follow the issue template!
- changed the title
[-]Param does not work from command line[/-][+]Param requires `None` to be explicitly passed from command line if it is a required argument[/+]on Jan 14, 2023 - changed the title
[-]Param requires `None` to be explicitly passed from command line if it is a required argument[/-][+]Param requires `None` to be explicitly passed as default[/+]on Jan 14, 2023 - changed the title
[-]Param requires `None` to be explicitly passed as default[/-][+]Required `Param` requires `None` to be explicitly passed as default[/+]on Jan 14, 2023 Marked it as good first issue. Hopefully somoene will fix it soon (but it's up for grabs for you if you would like to fix it ). PRs are most welcome to fix it.
Found out that you need to explicitly pass None as the default, otherwise it will crash with above.
For me it make sense. If no default value provided than parameter is a mandatory, and otherwise if default parameter provided than parameter is optional
I agree with @Taragolis, we should check if the required parameters (with no default value) are provided or not, and fail the dag run if they are not provided.
I'm working on a #29174 to deprecate dag run conf and support providing the params directly, and this exception will be raised before creating the dag run (code)It seems like currently we don't support required params, to fix this, I think we need to differentiate between parsing the params during the dag parsing/creation and parsing the params during the dag run execution.
During the dag parsing, we should not raise an exception if the default is not provided because this param is defined as required param. But during the dag run execution, if the param is required and the value is not provided, we should raise an exception to fail the dag run or the task if the params are defined at the task level.
I don't think this is a good first issue.
Reacted by Adrian Dankiv, Eugen and nicchristellerSure. Removed the label then
- added_eol_affected_version:2.5Issues Reported for 2.5Issues Reported for 2.5
on Feb 28, 2023 This is even worse for the case of a
Paramwith type of i.e. int. Then you need to pass a default value like -999.Reacted by Daniel Burkhardt Cerigo, Filipp Fisin, Adrian Dankiv, Tomáš Lipovský, Mati O, glalajcardo and SigheryThere had been a couple of PRs by me, for example #31301 and #34248 which handle optional fields and how Params are handled for this. Just got note of this bug report and must state after a manual re-test: Can not be re-produced. Did not explicitly test but might have been resolved in 2.8.0 already. Therefore closing.
Apache Airflow version
2.5.0
What happened
I have a dag like
I am trying to pass this param via CLI. I tried passing it like
gives
Note
Found out that you need to explicitly pass
Noneas the default, otherwise it will crash with above.What you think should happen instead
monthshould be passed to the dagHow to reproduce
No response
Operating System
mac osx
Versions of Apache Airflow Providers
No response
Deployment
Virtualenv installation
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct