Skip to content

Add missing tests for sftp exceptions #72268

Closed

Description

@jroachgolf84

Description

One module in the sftp provider has no dedicated test module, and (unlike most entries on the OVERLOOKED_TESTS list) it is not covered indirectly. Nothing under any providers/*/tests/ directory imports it at all:

Module Expected test file
providers/sftp/src/airflow/providers/sftp/exceptions.py providers/sftp/tests/unit/sftp/test_exceptions.py

It is currently suppressed in the OVERLOOKED_TESTS allowlist in airflow-core/tests/unit/always/test_project_structure.py.

This is a scoped subset of the meta issue #35442, limited to the sftp provider.

What should these tests cover?

The module defines a single exception, ConnectionNotOpenedException. Testing the class declaration on its own would be close to worthless, so the useful scope here is the behaviour that raises it, which turns out to be uncovered as well. The only raise site is the handle_connection_management decorator in providers/sftp/src/airflow/providers/sftp/hooks/sftp.py, and no test in providers/sftp/tests/ currently exercises that branch.

Worth covering:

  • a handle_connection_management wrapped hook method called with use_managed_conn false and no open connection raises ConnectionNotOpenedException, and the message points the caller at hook.get_managed_conn()
  • the same call with a connection already open delegates through to the wrapped function and returns its result
  • with use_managed_conn true the decorator opens a managed connection rather than raising, and the connection is set on the hook for the duration of the call
  • ConnectionNotOpenedException derives from AirflowException, which matters because callers catching the base class rely on that and narrowing it later would be a breaking change for them

The decorator can be driven against a small stub hook with a mocked connection, so no SFTP server is needed.

Definition of done

  1. Add the test module at the path in the table above.
  2. Remove the corresponding entry from OVERLOOKED_TESTS in airflow-core/tests/unit/always/test_project_structure.py
  3. This test should pass:
breeze testing providers-tests providers/sftp/tests/unit/sftp/test_exceptions.py

Drafted-by: Claude Code (Opus 5); reviewed and edited by @jroachgolf84 before posting.

Activity

  1. added
    contributors-workshop
    on Aug 29, 2026
  2. jroachgolf84 commented on Aug 29, 2026

    @jroachgolf84
    CollaboratorAuthor

    This is an issue that is reserved for the Airflow Summit "Contributors" Workshop. This is denoted with the label contributors-workshop. Out of respect for the organizers and participants of this workshop, please do not implement a PR that addresses this issue.

    If this issue is still open following Airflow Summit, the label will be removed and the issue can be picked up.

  3. added and removed
    contributors-workshop
    on Sep 2, 2026
  4. AkshayKarthickMS commented on Sep 23, 2026

    @AkshayKarthickMS

    Hi @jroachgolf84 I see the Airflow Summit workshop reservation is struck through. Is this issue open for contribution now? If so, I'd like to take it.

    I've already put together the test module covering the four cases listed above, using a stub hook with a mocked managed connection (no SFTP server needed), and removed the OVERLOOKED_TESTS entry. test_providers_modules_should_have_tests passes with it removed. Happy to open the PR once you confirm.

  5. added a commit that references this issue on Sep 23, 2026
    9290c26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions