Skip to content

Import ldap.filter in security_manager override#68226

Merged
vincbeck merged 1 commit into
apache:mainfrom
litesh1998:patch-1
Jun 8, 2026
Merged

Import ldap.filter in security_manager override#68226
vincbeck merged 1 commit into
apache:mainfrom
litesh1998:patch-1

Conversation

@litesh1998

Copy link
Copy Markdown
Contributor

Fix LDAP login failure caused by missing ldap.filter import

closes: #68224

When LDAP authentication is enabled, Airflow may return a 500 Internal Server Error during login.

The failure occurs in the LDAP search path where ldap.filter.escape_filter_chars() is called without importing the ldap.filter submodule first. With recent versions of python-ldap, importing ldap alone does not automatically expose the filter module, resulting in:

AttributeError: module 'ldap' has no attribute 'filter'

This change explicitly imports ldap.filter before it is used by the LDAP authentication flow.

Reproduction

  1. Configure Airflow with LDAP authentication.
  2. Install a recent version of python-ldap (e.g. 3.4.7).
  3. Attempt to log in using an LDAP user.
  4. Airflow returns HTTP 500 with:
AttributeError: module 'ldap' has no attribute 'filter'

Root Cause

ldap.filter.escape_filter_chars() is referenced during LDAP user lookup, but the ldap.filter module is not imported. Recent versions of python-ldap require the submodule to be imported explicitly.

Fix

Import ldap.filter before using ldap.filter.escape_filter_chars().

Testing

  • Reproduced the issue on:

    • Apache Airflow 3.2.2
    • apache-airflow-providers-fab 3.6.5
    • python-ldap 3.4.7
    • Python 3.12
  • Verified that LDAP authentication succeeds after the change.

  • Verified that the 500 Internal Server Error no longer occurs during login.

@boring-cyborg

boring-cyborg Bot commented Jun 8, 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: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@vincbeck vincbeck merged commit 21d37d3 into apache:main Jun 8, 2026
77 checks passed
@boring-cyborg

boring-cyborg Bot commented Jun 8, 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.

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jun 8, 2026
@dheerajturaga

dheerajturaga commented Jun 10, 2026

Copy link
Copy Markdown
Member

I just hit this issue on 3.2.2. Thanks for the fix @litesh1998 and congrats on your first contribution!

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

Labels

area:providers provider:fab ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LDAP Giving 500 Error

4 participants