[PR #234] [MERGED] fix: user-defined providers take precedence over built-in providers #253

Closed
opened 2026-06-06 22:09:54 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/234
Author: @octo-patch
Created: 4/4/2026
Status: Merged
Merged: 4/7/2026
Merged by: @asdek

Base: mainHead: fix/issue-220-user-defined-provider-precedence


📝 Commits (1)

  • a12ffe9 fix: user-defined providers take precedence over built-in providers (fixes #220)

📊 Changes

1 file changed (+15 additions, -11 deletions)

View changed files

📝 backend/pkg/providers/providers.go (+15 -11)

📄 Description

Fixes #220

Problem

GetProvider() in backend/pkg/providers/providers.go checked built-in providers first via a switch statement on the provider name. If the user-defined provider shared a name with a built-in one (e.g. "qwen"), the switch matched and returned the built-in provider, ignoring the user's custom configuration in the database.

Solution

Reverse the lookup order in GetProvider():

  1. Query the database for a user-defined provider with the given name first.
  2. If found (sql.ErrNoRows is not returned), build and return that provider — it takes precedence.
  3. Only if no user-defined provider exists (sql.ErrNoRows), fall back to the built-in provider switch.

This ensures that user-configured providers always override the defaults, regardless of whether the name matches a built-in provider.

Testing

Manually verified the logic flow:

  • When a user-defined provider named "qwen" exists in the DB, GetUserProviderByName returns it and the function returns the user-built provider without entering the switch.
  • When no user-defined provider exists for a name, sql.ErrNoRows causes the function to fall through to the built-in switch, preserving existing behavior for all other provider names.

🔄 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/vxcontrol/pentagi/pull/234 **Author:** [@octo-patch](https://github.com/octo-patch) **Created:** 4/4/2026 **Status:** ✅ Merged **Merged:** 4/7/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `main` ← **Head:** `fix/issue-220-user-defined-provider-precedence` --- ### 📝 Commits (1) - [`a12ffe9`](https://github.com/vxcontrol/pentagi/commit/a12ffe9c018291463fe84bc2e26cadc88b54c18e) fix: user-defined providers take precedence over built-in providers (fixes #220) ### 📊 Changes **1 file changed** (+15 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `backend/pkg/providers/providers.go` (+15 -11) </details> ### 📄 Description Fixes #220 ## Problem `GetProvider()` in `backend/pkg/providers/providers.go` checked built-in providers first via a `switch` statement on the provider name. If the user-defined provider shared a name with a built-in one (e.g. `"qwen"`), the switch matched and returned the built-in provider, ignoring the user's custom configuration in the database. ## Solution Reverse the lookup order in `GetProvider()`: 1. Query the database for a user-defined provider with the given name first. 2. If found (`sql.ErrNoRows` is not returned), build and return that provider — it takes precedence. 3. Only if no user-defined provider exists (`sql.ErrNoRows`), fall back to the built-in provider switch. This ensures that user-configured providers always override the defaults, regardless of whether the name matches a built-in provider. ## Testing Manually verified the logic flow: - When a user-defined provider named `"qwen"` exists in the DB, `GetUserProviderByName` returns it and the function returns the user-built provider without entering the switch. - When no user-defined provider exists for a name, `sql.ErrNoRows` causes the function to fall through to the built-in switch, preserving existing behavior for all other provider names. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:54 -04:00
yindo closed this issue 2026-06-06 22:09:54 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#253