Skip to content

Fix AttributeError: module 'ldap' has no attribute 'filter'#67535

Closed
m-rossi wants to merge 1 commit into
apache:mainfrom
m-rossi:ldap-issue
Closed

Fix AttributeError: module 'ldap' has no attribute 'filter'#67535
m-rossi wants to merge 1 commit into
apache:mainfrom
m-rossi:ldap-issue

Conversation

@m-rossi

@m-rossi m-rossi commented May 26, 2026

Copy link
Copy Markdown
Contributor

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

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@eladkal

eladkal commented May 26, 2026

Copy link
Copy Markdown
Contributor

can you add a unit test to avoid regression?
I assume we don't have a test that covers _search_ldap which resulted in this bug not being detected

@potiuk

potiuk commented May 26, 2026

Copy link
Copy Markdown
Member

I think it's mostly hallucinated. Can you explain (in human words) why this would work ? It seem to me that you have some badly name module called ldap in your deployment and this is your problem (and we warn against it in https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/modules_management.html

@potiuk potiuk closed this May 26, 2026
@m-rossi

m-rossi commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@potiuk You can simply test that my fix works by starting a Python shell where python-ldap is installed (for example your Airflow deployment of choice) and try

>>> import ldap
>>> ldap.filter.escape_filter_chars
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'ldap' has no attribute 'filter'

once you do my proposal, it works

>>> import ldap.filter
>>> ldap.filter.escape_filter_chars
<function escape_filter_chars at 0x7f469e678c20>

I found this solution in python-ldap/python-ldap#469 and it is related how the package python-ldap is structured.

I dig a little bit in the code and it seems like the ldap.filter.escape_filter_chars was introduced in #66417 and seems we have no testing on this ldap-part of the code which may have caught this?

So I ask you to reopen the PR and we should discuss about testing like @eladkal mentioned.

@m-rossi

m-rossi commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

For those of you who are looking for a workaround, you can put

import ldap.filter

in your airflow_local_settings.py while we wait for feedback from @potiuk or @eladkal (I don't want to clutter the PRs by opening another one).

@pcorliss

pcorliss commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Confirming that @m-rossi 's workaround above fixes the issue for us. I'd love to see this simple straightforward fix be re-opened and merged to fix this issue in mainline.

@pcorliss

pcorliss commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR was just merged in today with the same changes.

#68226

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.

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

4 participants