mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-21 08:15:23 -04:00
[PR #234] [MERGED] fix: user-defined providers take precedence over built-in providers #253
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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:
main← Head:fix/issue-220-user-defined-provider-precedence📝 Commits (1)
a12ffe9fix: 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()inbackend/pkg/providers/providers.gochecked built-in providers first via aswitchstatement 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():sql.ErrNoRowsis not returned), build and return that provider — it takes precedence.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:
"qwen"exists in the DB,GetUserProviderByNamereturns it and the function returns the user-built provider without entering the switch.sql.ErrNoRowscauses 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.