User gets error after few seconds because of LDAP error
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 18/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Domain
- authentication, backend
Research direction
The crash is in users/permissions.py at check_user_permission, which calls user.has_perm, and it fails inside django_auth_ldap when search_s receives a None base DN. Start by checking how the LDAP group search settings are read in the InvenTree settings and where the group base is passed to django_auth_ldap. Reproducing it needs an LDAP server, and the issue does not say which group setting is empty, so confirm that first. Done means a missing LDAP group setting no longer produces a TypeError on each request.
Written by the indexing model from the issue text.
Description
Please verify that this bug has NOT been raised before.
- I checked and didn't find a similar issue
Describe the bug*
When a new user logs in via LDAP, and I assign the correct group, then, even after relogin (and browser cache clearance etc). I get the following error:
Steps to Reproduce
- New user logs in using LDAP
- Assign correct group
- Relogin and clear browser
- go to parts overview and wait a few secondss
- Parts disappear and error appears.
Expected behaviour
No errors
Deployment Method
Docker
Version Information
InvenTree-Version: 1.1.1
Django Version: 4.2.25
Commit Hash: d3a58ea
Commit Date: 2025-11-03
Commit Branch: null
Database: django.db.backends.postgresql
Debug-Mode: True
Deployed using Docker: True
Platform: Linux-6.1.0-40-amd64-x86_64-with-glibc2.41
Installer: DOC
Active plugins: [{"name":"InvenTreeBarcode","slug":"inventreebarcode","version":"2.1.0"},{"name":"BOM Exporter","slug":"bom-exporter","version":"1.1.0"},{"name":"InvenTree Exporter","slug":"inventree-exporter","version":"1.0.0"},{"name":"Part Parameter Exporter","slug":"parameter-exporter","version":"1.0.0"},{"name":"InvenTreeEmailNotifications","slug":"inventree-email-notification","version":"1.0.0"},{"name":"InvenTreeUINotifications","slug":"inventree-ui-notification","version":"1.0.0"},{"name":"InvenTreeCurrencyExchange","slug":"inventreecurrencyexchange","version":"1.0.0"},{"name":"InvenTreeMachines","slug":"inventree-machines","version":"1.0.0"},{"name":"InvenTreeLabel","slug":"inventreelabel","version":"1.1.0"},{"name":"InvenTreeLabelMachine","slug":"inventreelabelmachine","version":"1.0.0"},{"name":"Altium BOM Importer","slug":"altium-bom-importer","version":"0.2.0"},{"name":"Altium Connector","slug":"altium-connector","version":"0.3.0"},{"name":"Custom BOM Exporter","slug":"custom_bom_exporter","version":"0.2.2"},{"name":"IPNGenerator","slug":"ipngen","version":"0.2"},{"name":"SolidWorks BOM Importer","slug":"solidworks-bom-importer","version":"0.2.0"},{"name":"Tree View","slug":"tree-view","version":"0.1.1"}]
Try to reproduce on the demo site
I did not try to reproduce
Is the bug reproducible on the demo site?
Not reproducible
Relevant log output
Traceback (most recent call last):
File "/root/.local/lib/python3.11/site-packages/rest_framework/views.py", line 512, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/rest_framework/views.py", line 526, in options
data = self.metadata_class().determine_metadata(request, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/inventree/src/backend/InvenTree/InvenTree/metadata.py", line 130, in determine_metadata
result = check_user_permission(user, self.model, permission) or (
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/inventree/src/backend/InvenTree/users/permissions.py", line 165, in check_user_permission
result = user.has_perm(permission_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django/contrib/auth/models.py", line 311, in has_perm
return _user_has_perm(self, perm, obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django/contrib/auth/models.py", line 220, in _user_has_perm
if backend.has_perm(user, perm, obj):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/backend.py", line 192, in has_perm
return perm in self.get_all_permissions(user, obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/backend.py", line 202, in get_all_permissions
return self.get_group_permissions(user, obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/backend.py", line 209, in get_group_permissions
permissions = user.ldap_user.get_group_permissions()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/backend.py", line 405, in get_group_permissions
self._load_group_permissions()
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/backend.py", line 841, in _load_group_permissions
group_names = self._get_groups().get_group_names()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/backend.py", line 949, in get_group_names
group_infos = self._get_group_infos()
^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/backend.py", line 996, in _get_group_infos
self._group_infos = self._group_type.user_groups(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/config.py", line 536, in user_groups
return search.execute(ldap_user.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django_auth_ldap/config.py", line 204, in execute
results = connection.search_s(
^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/ldap/ldapobject.py", line 631, in search_s
return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout=self.timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/ldap/ldapobject.py", line 624, in search_ext_s
msgid = self.search_ext(base,scope,filterstr,attrlist,attrsonly,serverctrls,clientctrls,timeout,sizelimit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/ldap/ldapobject.py", line 614, in search_ext
return self._ldap_call(
^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/ldap/ldapobject.py", line 128, in _ldap_call
result = func(*args,**kwargs)
^^^^^^^^^^^^^^^^^^^^
TypeError: search_ext() argument 1 must be str, not None
- Dominant language
- Python
- Stars
- 7.7k
- Forks
- 1.6k
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 204
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from inventree/InvenTree
-
enhancement triage:not-checked
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
inventree/InvenTree#13318 · 1 reaction ·
Maintainers usually reply within 1 day
-
enhancement User Interface wontfix
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
inventree/InvenTree#13292 · 5 comments ·
Maintainers usually reply within 1 day
-
[FR] Add spinner arrows in Quantity when adding a BOM itemMay be free again @Alonso-Lopez-1 claimed this 50 days ago, and no pull request is open. Openenhancement help wanted starter User Interface
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
inventree/InvenTree#12677 · 6 comments ·
Maintainers usually reply within 1 day
-
enhancement triage:not-checked
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
inventree/InvenTree#13317 · 1 reaction ·
Maintainers usually reply within 1 day
-
bug stock
Difficulty 3/5 1-2 days Newbie friendliness 40/100
inventree/InvenTree#13285 · 1 comment ·
Maintainers usually reply within 1 day
All issues in inventree/InvenTree
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ip-tools/patzilla#219 · 2 comments ·
Maintainers usually reply within 1 day
-
EPSSClient commits to its SQLite cache once per score: a 100-CVE bulk fetch makes 101 disk flushesOpenpriority:p3 technical-debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jimmy058910/jmo-security-repo#1673 ·
Maintainers usually reply within 1 day
-
enhancement ready
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
integration: frontier_silicon
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
home-assistant/core#193176 · 2 comments ·
Maintainers usually reply within 1 day
-
task create and task update take --body-file and --stdinPossibly taken @JuanBarriosS claimed this today. Opencli enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
pyrite-wiki/pyrite#1687 · 1 comment ·
Maintainers usually reply within 1 day