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
Copy link
Copy Markdown
Contributor

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


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
Copy link
Copy Markdown
Contributor

eladkal commented May 26, 2026

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
Copy link
Copy Markdown
Member

potiuk commented May 26, 2026

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
Copy link
Copy Markdown
Contributor Author

m-rossi commented May 27, 2026

@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.

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'

3 participants