[PR #21478] [CLOSED] fix: resolve PostgreSQL GROUP BY error in /api/v1/groups/ endpoint #41725

Closed
opened 2026-04-25 13:53:26 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21478
Author: @Classic298
Created: 2/16/2026
Status: Closed

Base: devHead: fix-api-groups


📝 Commits (4)

  • 04e4c43 fix: resolve PostgreSQL GROUP BY error in /api/v1/groups/ endpoint (#151)
  • 2586f1f Merge branch 'dev' into fix-api-groups
  • ae056e2 Fix search_groups to use get_group_member_counts_by_ids (#152)
  • 699f0c8 whitespace and simplified query for psql

📊 Changes

1 file changed (+35 additions, -34 deletions)

View changed files

📝 backend/open_webui/models/groups.py (+35 -34)

📄 Description

Replace JOIN-based member filtering with IN subqueries across all group query methods. JOINing Group with GroupMember and using GROUP BY only on Group.id fails on PostgreSQL because all non-aggregated columns must appear in GROUP BY. Using IN subqueries avoids the JOIN entirely, preventing both the GROUP BY error and potential duplicate rows.

Also fix model_validate kwargs bug in search_groups and remove debug print statement.

Bonus fixes:

  • Fixed search_groups calling model_validate(**kwargs) instead of model_validate({dict}) — this would have crashed at runtime
  • Removed a stray print("Filtering by share:", ...) debug statement

Fixes #21467

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21478 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 2/16/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-api-groups` --- ### 📝 Commits (4) - [`04e4c43`](https://github.com/open-webui/open-webui/commit/04e4c43eac40bedd8950d046484c843445379239) fix: resolve PostgreSQL GROUP BY error in /api/v1/groups/ endpoint (#151) - [`2586f1f`](https://github.com/open-webui/open-webui/commit/2586f1f39273cacddb86fb6d793141d663b79803) Merge branch 'dev' into fix-api-groups - [`ae056e2`](https://github.com/open-webui/open-webui/commit/ae056e28a5553307a761a77d139f2cd1483d54f9) Fix search_groups to use get_group_member_counts_by_ids (#152) - [`699f0c8`](https://github.com/open-webui/open-webui/commit/699f0c81169ec7d512959c64a3c7be71f4281e07) whitespace and simplified query for psql ### 📊 Changes **1 file changed** (+35 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/groups.py` (+35 -34) </details> ### 📄 Description Replace JOIN-based member filtering with IN subqueries across all group query methods. JOINing Group with GroupMember and using GROUP BY only on Group.id fails on PostgreSQL because all non-aggregated columns must appear in GROUP BY. Using IN subqueries avoids the JOIN entirely, preventing both the GROUP BY error and potential duplicate rows. Also fix model_validate kwargs bug in search_groups and remove debug print statement. Bonus fixes: - Fixed search_groups calling model_validate(**kwargs) instead of model_validate({dict}) — this would have crashed at runtime - Removed a stray print("Filtering by share:", ...) debug statement Fixes #21467 ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 13:53:26 -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#41725