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

   ### Apache Airflow Provider(s)
   
   apache-beam
   
   ### Versions of Apache Airflow Providers
   
   Reproduced in 5.3.0 but probably affects up to 5.6.2
   
   ### Apache Airflow version
   
   2.6.3
   
   ### Operating System
   
   macOS 14.1.1
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   The Beam hook is parsing options passed to the pipeline incorrectly if the 
value is `False`.
   
   According to the docs, if the value is False, the option will be skipped. 
This is consistent with the Apache Beam pipeline options behaviour and makes it 
possible to define flag pipeline options. Setting a `foo` option as `True` in 
the provider operators `pipeline_options` and `default_pipeline_options` 
parameters would pass `--foo` to the Beam pipeline, while setting it to `False` 
should skip it, effectively acting as a flag argument.
   
   However, the code in 
https://github.com/apache/airflow/blob/b402f8a35633beb4a41e09365a57008c67d377e8/airflow/providers/apache/beam/hooks/beam.py#L66
 is not skipping the option if the value is `False`. Instead, it's applying the 
default behaviour of replacing the value with its textual representation.
   
   ### What you think should happen instead
   
   The option should be skipped if the value is False.
   
   ### How to reproduce
   
   ```python
   from airflow import models
   from airflow.providers.apache.beam.operators.beam import 
BeamRunPythonPipelineOperator
   from airflow.utils import timezone
   
   with models.DAG(dag_id="beam-option", start_date=timezone.datetime(2024, 1, 
1)) as dag:
       beam_operator = BeamRunPythonPipelineOperator(
           task_id="beam-operator",
           py_file="my_file.py",
           runner="DirectRunner",
           pipeline_options={"flag_option_true": True, "flag_option_false": 
False},
       )
   ```
   
   Running this DAG will log:
   ```
   [2024-03-25T12:52:19.067+0100] {beam.py:131} INFO - Running command: python3 
my_file.py --runner=DirectRunner --flag_option_true --flag_option_false=False 
--labels=airflow-version=v2-6-3
   ```
   instead of the expected without the `flag_option_false` option.
   
   ### 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