Skip to content

fix: user-defined providers take precedence over built-in providers#234

Merged
asdek merged 1 commit intovxcontrol:mainfrom
octo-patch:fix/issue-220-user-defined-provider-precedence
Apr 8, 2026
Merged

fix: user-defined providers take precedence over built-in providers#234
asdek merged 1 commit intovxcontrol:mainfrom
octo-patch:fix/issue-220-user-defined-provider-precedence

Conversation

@octo-patch
Copy link
Copy Markdown
Contributor

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.

@salecharohit
Copy link
Copy Markdown

#233 related ?

@asdek asdek merged commit 36ac0c8 into vxcontrol:main Apr 8, 2026
@asdek
Copy link
Copy Markdown
Contributor

asdek commented Apr 8, 2026

@octo-patch Thank you for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: User-defined Qwen provider is ignored when name matches built-in provider

3 participants