Skip to content

LDAP group search misconfiguration results in HTTP 500 during requests #12225

Description

@markusEmm123

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

When LDAP authentication is enabled and group permission lookup is active,
an invalid or missing LDAP group search base can cause runtime HTTP 500
errors during normal API requests.

Example configuration:

ldap:
  enabled: true
  find_group_perms: true

No valid ldap.group_search is configured.

In this situation InvenTree starts normally and user authentication works.

However, later requests trigger LDAP group lookups and fail with:

search_ext() argument 1 must be str, not None
Debug output shows:

Invoking search_s(
    'None',
    2,
    '(&(objectClass=groupOfUniqueNames)(uniqueMember=...))'
)

This eventually produces HTTP 500 responses.

Steps to Reproduce

  1. Enable LDAP
  2. Leave ldap.group_search undefined
  3. Enable group permission lookup
  4. Log in successfully
  5. Access API endpoints requiring permission evaluation (just wait some time in the "parts" view)
  6. Observe UI error and search_s('None', ...) in log files

Expected behaviour

  • Fail during startup with a clear configuration error, or
  • Disable group lookups automatically when group_search is not configured, or
  • Return a meaningful LDAP configuration error instead of HTTP 500.

Deployment Method

Docker

Version Information

InvenTree 1.3.0
django-auth-ldap 5.3.0

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

Invoking search_s('None', 2, '(&(objectClass=groupOfUniqueNames)(uniqueMember=cn=<cn of user>))')

2026-06-22 21:15:18,421 DEBUG Invoking search_s('None', 2, '(&(objectClass=groupOfUniqueNames)(uniqueMember=<cn of user>))')

2026-06-22T21:15:18.429288Z [error    ] search_ext() argument 1 must be str, not None [inventree] ip=95.90.8.162 request_id=15cd907d-97e6-45d1-81ec-9a7cec891f2c user_id=6

2026-06-22 21:15:18,429 ERROR {'event': TypeError('search_ext() argument 1 must be str, not None'), 'ip': 'IP', 'request_id': '15cd907d-97e6-45d1-81ec-9a7cec891f2c', 'user_id': 6, 'timestamp': '2026-06-22T21:15:18.429288Z', 'logger': 'inventree', 'level': 'error'}

2026-06-22T21:15:18.485530Z [error    ] request_finished               [django_structlog.middlewares.request] code=500 ip=95.90.8.162 request='OPTIONS /api/part/category/?top_level=true' request_id=15cd907d-97e6-45d1-81ec-9a7cec891f2c user_id=6

2026-06-22 21:15:18,485 ERROR {'code': 500, 'request': 'OPTIONS /api/part/category/?top_level=true', 'event': 'request_finished', 'ip': '<IP>', 'request_id': '15cd907d-97e6-45d1-81ec-9a7cec891f2c', 'user_id': 6, 'timestamp': '2026-06-22T21:15:18.485530Z', 'logger': 'django_structlog.middlewares.request', 'level': 'error'}

2026-06-22 21:15:18,486 ERROR Internal Server Error: /api/part/category/

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIdentifies a bug which needs to be addressedinactiveIndicates lack of activityquestionThis is a questiontriage:not-checkedItem was not checked by the core team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions