[GH-ISSUE #22856] Bug: TypeError in get_license_data() when LICENSE_BLOB has missing/None exp field #123139

Closed
opened 2026-05-21 02:21:53 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @themavik on GitHub (Mar 19, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/22856

Bug Description

In backend/open_webui/utils/auth.py, the get_license_data() function has a logic error in the license expiration check that causes a TypeError when the exp field is missing or None.

Code Location

backend/open_webui/utils/auth.py:

if not data.get("exp") and data.get("exp") < datetime.now().date():
    return False

Problem

The condition uses and instead of or. When exp is missing or None:

  1. not data.get("exp") evaluates to True (since None is falsy)
  2. Due to and, Python evaluates the second condition: None < datetime.now().date()
  3. This raises: TypeError: '<\ not supported between instances of 'NoneType' and 'datetime.date'

Reproduction

data = {"exp": None}
if not data.get("exp") and data.get("exp") < datetime.now().date():
    return False
# TypeError: '<\ not supported between instances of 'NoneType' and 'datetime.date'

Suggested Fix

if not data.get("exp") or data.get("exp") < datetime.now().date():
    return False

This correctly returns False when exp is missing (treat as expired) OR when exp is in the past.

Environment

  • Observed on latest main branch
Originally created by @themavik on GitHub (Mar 19, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/22856 ## Bug Description In `backend/open_webui/utils/auth.py`, the `get_license_data()` function has a logic error in the license expiration check that causes a `TypeError` when the `exp` field is missing or `None`. ## Code Location `backend/open_webui/utils/auth.py`: ```python if not data.get("exp") and data.get("exp") < datetime.now().date(): return False ``` ## Problem The condition uses `and` instead of `or`. When `exp` is missing or `None`: 1. `not data.get("exp")` evaluates to `True` (since `None` is falsy) 2. Due to `and`, Python evaluates the second condition: `None < datetime.now().date()` 3. This raises: `TypeError: '<\ not supported between instances of 'NoneType' and 'datetime.date'` ## Reproduction ```python data = {"exp": None} if not data.get("exp") and data.get("exp") < datetime.now().date(): return False # TypeError: '<\ not supported between instances of 'NoneType' and 'datetime.date' ``` ## Suggested Fix ```python if not data.get("exp") or data.get("exp") < datetime.now().date(): return False ``` This correctly returns `False` when `exp` is missing (treat as expired) OR when `exp` is in the past. ## Environment - Observed on latest main branch
GiteaMirror added the bug label 2026-05-21 02:21:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#123139