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

   ### Apache Airflow version
   
   2.7.3
   
   ### What happened
   
   `DockerOperator`'s [`env_file` 
param](https://github.com/apache/airflow/blob/f8dd19248345ac259153812c68b65fc39accfcfd/airflow/providers/docker/operators/docker.py#L100-L101)
 is documented to accept a path:
   
   >     :param env_file: Relative path to the ``.env`` file with environment 
variables to set in the container.
   >        Overridden by variables in the environment parameter. (templated)
   
   However, 
[`unpack_environment_variables()`](https://github.com/apache/airflow/blob/f8dd19248345ac259153812c68b65fc39accfcfd/airflow/providers/docker/operators/docker.py#L528-L535)
 is implemented to load the `str` param as _file_contents_ and not a _path_.
   
   Bug seems to have existed since the feature's introduction: 
https://github.com/apache/airflow/pull/26951
   
   ### What you think should happen instead
   
   Should load the path `.env` or other passed in path instead. The use of 
`StringIO` seems like a leftover artifact of testing.
   
   Although there's the option to consider the implemented functionality as 
"correct" and deem this a documentation bug, a "pass in file contents as text" 
interface is not desirable compared to the behavior as documented, esp since 
it's preferable to match the interface of [`docker 
run`](https://docs.docker.com/engine/reference/commandline/run/), which states:
   
   > `--env-file`                       Read in a file of environment variables
   
   Implementation Notes:
   
    * The `unpack_environment_variables()` function is wholly unnecessary, 
providing little to no abstraction value. Should just inline the call to 
`dotenv_values()`.
    * `dotenv_values()` is nicely typed, accepting a `dotenv.StrPath` type as 
the first arg. `DockerOperator`'s `env_file` param use the same annotated type 
(specifically, `str | os.PathLike[str] | None`, or `dotenv.StrPath | None`)
   
   ### How to reproduce
   
   Use `DockerOperator` as written in 
[tests](https://github.com/apache/airflow/pull/26951/files#diff-942f75ae382d164822ff30e8138471be26102283dfcbf25e6f1c8e5795de0cb0R99)
   
   ### Operating System
   
   n/a
   
   ### Versions of Apache Airflow Providers
   
   ```
   name = "apache-airflow-providers-docker"
   version = "3.8.1"
   ```
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   n/a
   
   ### Anything else
   
   What's Airflow's SOP on minor breaking changes? Is it necessary to have a 
whole deprecation cycle of `warnings` etc for this?
   
   ### Are you willing to submit PR?
   
   - [X] 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: commits-unsubscr...@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to