[GH-ISSUE #10489] TypeError in update_user_groups for Non-Admin Users #102905

Closed
opened 2026-05-18 00:17:00 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @jeannotdamoiseaux on GitHub (Feb 21, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/10489

Affected File:
backend/open_webui/utils/oauth.py

Description:
When a non-admin user logs in via OAuth, the application throws a TypeError in the update_user_groups function. This error occurs because the variable user_oauth_groups is set to None when the OAuth groups claim is not provided as a list. Consequently, operations like membership checks (e.g., if group_model.name not in user_oauth_groups) fail since None is not iterable and the application does not start.

Steps to Reproduce:

  1. Configure OAuth such that the OAUTH_GROUPS_CLAIM does not yield a list for non-admin users.
  2. Log in using a non-admin account.
  3. Observe the error in the logs: TypeError: argument of type 'NoneType' is not iterable
  4. The error is triggered in the function update_user_groups located in backend/open_webui/utils/oauth.py.

Expected Behavior:
The application should handle the scenario by ensuring that user_oauth_groups is always an iterable (e.g., an empty list when no groups are provided), allowing the login and group update processes to complete without error.

Actual Behavior:
The code assigns user_oauth_groups to None if the claim data is not a list:

user_oauth_groups = claim_data if isinstance(claim_data, list) else None

This causes a TypeError when attempting to iterate or check membership.

Proposed Fix:
Modify the assignment to default to an empty list instead of None:

user_oauth_groups = claim_data if isinstance(claim_data, list) else []

Please let me know what you think.

Originally created by @jeannotdamoiseaux on GitHub (Feb 21, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/10489 **Affected File:** [backend/open_webui/utils/oauth.py](https://github.com/OpenWebUI/OpenWebUI/blob/main/backend/open_webui/utils/oauth.py) **Description:** When a non-admin user logs in via OAuth, the application throws a `TypeError` in the `update_user_groups` function. This error occurs because the variable `user_oauth_groups` is set to `None` when the OAuth groups claim is not provided as a list. Consequently, operations like membership checks (e.g., `if group_model.name not in user_oauth_groups`) fail since `None` is not iterable and the application does not start. **Steps to Reproduce:** 1. Configure OAuth such that the `OAUTH_GROUPS_CLAIM` does not yield a list for non-admin users. 2. Log in using a non-admin account. 3. Observe the error in the logs: `TypeError: argument of type 'NoneType' is not iterable` 4. The error is triggered in the function `update_user_groups` located in `backend/open_webui/utils/oauth.py`. **Expected Behavior:** The application should handle the scenario by ensuring that `user_oauth_groups` is always an iterable (e.g., an empty list when no groups are provided), allowing the login and group update processes to complete without error. **Actual Behavior:** The code assigns `user_oauth_groups` to `None` if the claim data is not a list: ```python user_oauth_groups = claim_data if isinstance(claim_data, list) else None ``` This causes a `TypeError `when attempting to iterate or check membership. Proposed Fix: Modify the assignment to default to an empty list instead of None: ```python user_oauth_groups = claim_data if isinstance(claim_data, list) else [] ``` Please let me know what you think.
Author
Owner

@tjbck commented on GitHub (Feb 21, 2025):

PR welcome!

<!-- gh-comment-id:2675204230 --> @tjbck commented on GitHub (Feb 21, 2025): PR welcome!
Author
Owner

@jeannotdamoiseaux commented on GitHub (Feb 21, 2025):

PR welcome!

@tjbck , please see #10549.

<!-- gh-comment-id:2675583198 --> @jeannotdamoiseaux commented on GitHub (Feb 21, 2025): > PR welcome! @tjbck , please see #10549.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#102905