Skip to content

Fix SSH provider imports when sshtunnel is broken on Python 3.14 (#64258) - #64277

Closed
deepujain wants to merge 2 commits into
apache:mainfrom
deepujain:fix-64258-ssh-provider-py314-sshtunnel
Closed

deepujain wants to merge 2 commits into
apache:mainfrom
deepujain:fix-64258-ssh-provider-py314-sshtunnel

Conversation

@deepujain

Copy link
Copy Markdown
Contributor

Summary

The SSH provider imported sshtunnel at module import time, so Python 3.14 environments with the current incompatible sshtunnel release could fail on plain imports like SFTPHook before any tunnel functionality was used. This change defers the sshtunnel import until get_tunnel() is called and raises a clear optional-feature error if the dependency is unavailable or syntactically incompatible.

Changes

  • providers/ssh/src/airflow/providers/ssh/hooks/ssh.py -- lazy-load sshtunnel only when tunnel creation is requested and raise AirflowOptionalProviderFeatureException on import/runtime incompatibility.
  • providers/ssh/tests/unit/ssh/hooks/test_ssh.py -- add regression coverage for importing SSHHook when sshtunnel is broken and for the runtime error path when tunnel support is used.

Test plan

  • uv run --project providers/sftp python - <<'PY' smoke import of from airflow.providers.sftp.hooks.sftp import SFTPHook
  • uv run --project providers/sftp pytest providers/ssh/tests/unit/ssh/hooks/test_ssh.py -k 'test_tunnel_with_password or test_tunnel_without_password or test_tunnel_with_private_key or test_tunnel_with_private_key_passphrase or test_tunnel_with_private_key_ecdsa or test_can_import_ssh_hook_when_sshtunnel_is_broken or test_tunnel_requires_working_sshtunnel' -xvs
  • CI passes (ruff, mypy, pytest)

Fixes #64258

@deepujain
deepujain force-pushed the fix-64258-ssh-provider-py314-sshtunnel branch from 250cc06 to 9d7d871 Compare March 27, 2026 04:39
@eladkal

eladkal commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

I don't think this is the right fix.
The idea is to make the provider compatible with Python 3.14 not just hide an import that does not work.

@eladkal

eladkal commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Closing in favor of #64299

@eladkal eladkal closed this Mar 27, 2026
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.

ssh provider incompatible with py3.14 due to outdated sshtunnel dependency

2 participants