tawsifh opened a new issue #20735:
URL: https://github.com/apache/airflow/issues/20735


   ### Apache Airflow Provider(s)
   
   sftp
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-amazon==2.6.0
   apache-airflow-providers-apache-hdfs==2.2.0
   apache-airflow-providers-apache-hive==2.1.0
   apache-airflow-providers-apache-livy==2.1.0
   apache-airflow-providers-apache-spark==2.0.3
   apache-airflow-providers-celery==2.1.0
   apache-airflow-providers-elasticsearch==2.1.0
   apache-airflow-providers-ftp==2.0.1
   apache-airflow-providers-google==4.0.0
   apache-airflow-providers-http==2.0.1
   apache-airflow-providers-imap==2.0.1
   apache-airflow-providers-jira==2.0.1
   apache-airflow-providers-postgres==2.4.0
   apache-airflow-providers-redis==2.0.1
   **apache-airflow-providers-sftp==2.4.0**
   apache-airflow-providers-slack==4.1.0
   apache-airflow-providers-sqlite==2.0.1
   **apache-airflow-providers-ssh==2.3.0**
   
   
   ### Apache Airflow version
   
   2.2.3 (latest released)
   
   ### Operating System
   
   Ubuntu 20.04
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   I believe this was introduced in this commit 
https://github.com/apache/airflow/commit/f35ad27080a2e1f29efc20a9bd0613af0f6ff2ec
   In File airflow/providers/sftp/hooks/sftp.py
   In lines 74-79
   ```python
       def __init__(
           self,
           ssh_conn_id: Optional[str] = 'sftp_default',
           ftp_conn_id: Optional[str] = 'sftp_default',
           *args,
           **kwargs,
       ) -> None:
   
           if ftp_conn_id:
               warnings.warn(
                   'Parameter `ftp_conn_id` is deprecated.' 'Please use 
`ssh_conn_id` instead.',
                   DeprecationWarning,
                   stacklevel=2,
               )
               kwargs['ssh_conn_id'] = ftp_conn_id
           self.ssh_conn_id = ssh_conn_id
           super().__init__(*args, **kwargs)
   ```
   Since `ftp_conn_id` has a default value of `sftp_default`, it will always 
override `ssh_conn_id` unless explicitly set to None during init.
   
   ### What you expected to happen
   
   If you initialise the hook with `ssh_conn_id` parameter it should use that 
connection instead of ignoring the parameter and using the default value. 
   The deprecation message is also triggered despite only passing in 
`ssh_conn_id`
   `<stdin>:1 DeprecationWarning: Parameter `ftp_conn_id` is deprecated.Please 
use `ssh_conn_id` instead.`
   
   ### How to reproduce
   
   ```python
   from airflow.providers.sftp.hooks.sftp import SFTPHook
   hook = SFTPHook(ssh_conn_id='some_custom_sftp_conn_id')
   ```
   
   There will be a log message stating
   `[2022-01-07 01:12:05,234] {base.py:70} INFO - Using connection to: id: 
sftp_default.` 
   
   ### Anything else
   
   This breaks the SFTPSensor and SFTPOperator
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to