Skip to content

Honor string passive extra in FTPHook and FTPSHook - #73694

Merged
shahar1 merged 1 commit into
apache:mainfrom
SulimanAbdulrazzaq:fix/ftp-passive-string-extra
Sep 25, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
SulimanAbdulrazzaq:fix/ftp-passive-string-extra

Conversation

@SulimanAbdulrazzaq

Copy link
Copy Markdown

FTPHook.get_conn() and FTPSHook.get_conn() pass the passive connection extra straight to ftplib.FTP.set_pasv(). If the value is a string, every non-empty value is truthy, so "false" leaves passive mode on and active mode can't be selected. The hook docstring shows the extra as a string ({"passive": "true"}), and URI-style connections store it as a string where query values aren't JSON-decoded. For example, the documented AIRFLOW_CONN_FTP_DEFAULT='ftp://user:pass@localhost?passive=false' on Airflow 2.11, which the provider still supports.

This PR adds a small helper that turns string values ("false", "0", "no", "off", case-insensitive) into a boolean and passes booleans through unchanged. Both hooks use it. The default is still passive mode.

Tests: new parametrized test_ftp_mode_from_string_extra and test_ftps_mode_from_string_extra for {"passive": "false"} and {"passive": "true"}. Before the fix they fail with Expected: set_pasv(False) / Actual: set_pasv('false'). With the fix, the whole FTP provider unit suite passes (61 passed).


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines

A passive value given as a string, such as {"passive": "false"}, was
passed straight to set_pasv(), where any non-empty string is truthy, so
active mode could not be selected that way. Parse string values before
using them in both hooks.
@boring-cyborg

boring-cyborg Bot commented Sep 24, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@shahar1
shahar1 merged commit 3a5fe2f into apache:main Sep 25, 2026
79 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 25, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants